Reputation: 1503
I'm working on a Wordpress database model in which I have added many custom post types with taxonomies in the following layout
function my_custom_settings(){
register_post_type( 'my_custom_post_type',array(
'labels' => array(
'name' => __( 'My Custom Post Type' ),
'singular_name' => __('My Custom Post Type')
),
'public' => true,
'menu_position' => 6,
'rewrite' => array(
'slug' => 'my-custom-post-type',
'with_front' => true,
)));
register_taxonomy('my_custom_taxonomy','my_custom_post_type',array(
'hierarchical' => true,
'label' => 'My Custom Taxonomy',
'query_var' => true,
'rewrite' => array('slug' => 'my-custom-taxonomy')
));
}
add_action('init','my_custom_settings');
I was wondering if it is possible to change the namespace of the actual registered post type (e.g. my_custom_post_type
to my_other_custom_post_type
) while keeping the database relations and posts in tact. My problem is that a lot of the post types have similar namespaces which is becoming confusing, so I guess I need to know the specific database fields to change and was wondering if someone knows the locations and/or if there is an easer method of renaming custom post types. Thanks in advance!
Upvotes: 0
Views: 1604
Reputation: 87
Recently I had to migrate a site and export all custom post type from Web A to web B, In order to rename the post from Site A to site B, I export all post using wordpress exporter tool. The problem is web B already had the same post name created (old_post_type_name) and I need to import the data to a new custom post type (new_post_type_name). Once you have the XML file generated by wordpress export tool , open in using Notepad++ or any other editor, use search and replace and look for:
<wp:post_type><![CDATA[old_post_type_name]]></wp:post_type>
you have to rename old_post_type_name to new_post_type_name
<wp:post_type><![CDATA[old_post_type_name]]></wp:post_type>
to
<wp:post_type><![CDATA[new_post_type_name]]></wp:post_type>
Save the file and import to wordpress using tools-> import, upload the XML file you have modified and that´s all.
Hope it helps
Upvotes: 0
Reputation: 398
Something along these lines?
UPDATE `wp_posts` SET `post_type` = '<new post type name>' WHERE `post_type` = '<old post type name>';
Upvotes: 3