How can I convert Posts into Custom type posts?

I have a WordPress site that I just updated to 3.1. I want to make use of custom post types now, my question is how can I assign (transfer?) a post to a newly created custom post type ?

For example, all my articles (news, poems, ideas to change the world) are in Posts. Now I have created the custom post types News, Poems, etc. and I want to transfer my old posts to these new custom post types.

Read More

I hope this is clear enough, anybody ?

Related posts

Leave a Reply

6 comments

  1. For those who are looking for a code solution:

    $post_id             = 123; // Set this to the ID of the post you want to update.
    $post_obj            = get_post( $post_id );
    $post_obj->post_type = 'custom-post-type'; // Set this to the slug of your custom post type.
    wp_update_post( $post_obj );    
    
  2. This query will convert all posts to a different post type. You need to make sure that both the previous and new post types share the same categories and taxonomies when you register it with register_post_type.

    UPDATE `wp_posts` SET `post_type` = 'blog' WHERE `post_type` = 'post';