I have a clean WordPress installation using Twenty Eleven, with no plugins or other modifications. The blog contains approximately 800 posts with related tags and categories.
I'd like to move all these posts to a custom post type. By adding the following code to my functions.php my blog now has the custom post type installed and working perfectly.
//Add custom post type
add_action( 'init', 'create_en_post_type' );
function create_en_post_type() {
register_post_type( 'en_post', array(
'labels' => array(
'name' => __( 'English Posts' ),
'singular_name' => __( 'English Post' )
),
'public' => true,
'menu_position' => 5,
'rewrite' => array('slug' => 'en'),
'supports' => array(
'title',
'editor',
'author',
'excerpt',
'comments',
'custom-fields'
)
));
}
//Add belonging custom taxonomy
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
register_taxonomy( 'english_categories', 'en_post', array( 'hierarchical' => true, 'label' => 'English Categories', 'query_var' => true, 'rewrite' => true ) );
register_taxonomy( 'english_tags', 'en_post', array( 'hierarchical' => false, 'label' => 'English Tags', 'query_var' => true, 'rewrite' => true ) );
}
Now all I need is to change the regular post type to my custom post type. I've managed to move the posts using the plugin Convert Post Types, but my taxonomies aren't converted.
I realize I could just create similar custom categories and assign the custom posts to them, but what about tags? How can I convert these (automatically, 1200 tags)?
I've tried manually messing around in the database, but I can't make it work.
You should change the ID's in the database, take a long look at the phpmyadmin
In the terms table you will find the id of the old and new taxamonies
in term_taxonomy replace all old
term_id
with the new.SQL:
Do make a backup before you start