phpmysqlwordpress

How to rename custom post type


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!


Solution

  • Something along these lines?

    UPDATE  `wp_posts` SET  `post_type` =  '<new post type name>' WHERE  `post_type` = '<old post type name>';