Is it possible to convert wordpress custom post type to normal categories

Currently our site’s videos are posted as custom post type. We have totally changed the theme and added so many new features. For our new site we are trying to change videos to category. (Custom post type to normal categories). Is this possible. I have exported the custom post type as XML file, but I don’t know how to change it to categories.

Related posts

Leave a Reply

1 comment

  1. Finally an answer. Before I start These are the conditions I’m using.

    • The Custom posttype (called video) need to be merged into the default post
    • Video’s has it own custom categories, who needs to be merged into the default categories
    • All Video’s need to get a category video, the old categories need to be children of the newly created video category.

    Step Zero: BACKUP my sql BACKUP

    First create a the video category in the default posttype. Note it’s ID (it is found in the category edit page in the url under tag_ID. I’m assuming ID 4 in my examples

    Second we assign this category to the video posttype with the following Sql:

    INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`)
    SELECT `ID`, '4' FROM `wp_posts` WHERE `post_type` = 'video';
    

    Next we assign the existing custom categories as children. You need the video category slug, found on the custom-category page agian in the url with taxonomy.

    UPDATE `wp_term_taxonomy` SET `parent` = 4, `taxonomy` = 'category' WHERE `taxonomy` = 'VIDEO CATEGORYSLUG';
    

    The last step is assigning the normal posttype to the custom posttype.

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

    Now it should be done and everything should be merged. So TEST TEST TEST.
    After that the code making the posttype can be disabled.

    This should work, if you have questions just ask.