Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Switch Post Type in WordPress

How to Switch Post Type in WordPress

This is a very short tutorial which will let to know how to Switch post type in Wordpress sites.

In this tutorial, I will share a simple code snippet which allows you to switch post type and also I have shared a WordPress Plugin named Post Type Switcher.

How to Switch Post Type in WordPress

Use the below code at the end of the functions.php file and save. It will allow you to switch the post type from page to post and post to a page.

 * Switch post type
function switch_post_type ( $old_post_type, $new_post_type ){
	global $wpdb;

	// Run the update query
		// Set
		array( 'post_type' => $new_post_type),
		// Where
		array( 'post_type' => $old_post_type )

If you don’t want to use this code, then use Post Type Switcher WordPress plugin by John James Jacoby. This plugin will add a simple post-type drop-down on the post editor screen to switch the post type.

By using the Post Type Switcher plugin you can convert nearly every combination of posts, pages, and even custom post types:

  1. Page to Post
  2. Post to Page
  3. Post to Custom
  4. Custom to Custom

How to install Post Type Switcher plugin

The installation of this very simple as other plugins. If you have just started with WordPress, then check out:

  • How to Install a WordPress Plugin

After the installation, click on Activate button to enable the plugin features on your WordPress site. See the below screenshots how it will look like after activated:


How to Switch Post Type in WordPress-2

Hope this code will help you. Please do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.

The post How to Switch Post Type in WordPress appeared first on FreeWebMentor.

This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

How to Switch Post Type in WordPress


Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription