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.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/** * Switch post type */ function switch_post_type ( $old_post_type, $new_post_type ){ global $wpdb; // Run the update query $wpdb->update( $wpdb->posts, // 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:
The installation of this very simple as other plugins. If you have just started with WordPress, then check out:
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:
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.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: change page to post wordpress, how do i change a post to a page in wordpress, how to change a post to a page in wordpress, post type switcher wordpress, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners