Programmatically Change post_type

By Alex on August 18 2010 | Listed under WordPress | 2 Comments

Now that WordPress 3.0 is out, everyone is wanting to use Custom Post Types. But what if you have a load of posts that you want to convert to a new custom post type?

If Custom Post Types are new to you, I seriously recommend you check out Justin Tadlock’s article on them, as well as looking at all of Shibashake’s stuff.

This is a really simple tip, and is as follows:

UPDATE wp_posts SET post_type = REPLACE (post_type, 'post', 'custom_type');

This would update all posts with the post type ‘post’ to have the post type ‘custom_type’. Use with caution, and don’t forget to backup your DB before running the query.

This could even be made into a plugin to make it more manageable for a non-tech user.

31 Days to Build a Better Blog Affiliate Link

Did you enjoy this post? If you did, so might others! Please share it!

2 Comments - Add Yours!

Post a Comment

Your email is never published nor shared.

*
*
User Gravatar