I’m trying to register custom post type this way:
add_action( 'init', 'vocabulary_register_post_type' );
function vocabulary_register_post_type() {
$labels = array(
'name' => 'SÅowniczek',
'singular_name' => 'PojÄcie',
'menu_name' => 'PojÄcia',
'name_admin_bar' => 'PojÄcie',
'add_new' => 'Dodaj nowe pojÄcie',
'add_new_item' => 'Dodaj nowe pojÄcie',
'edit_item' => 'Edytuj pojÄcie',
'new_item' => 'Nowe pojÄcie',
'view_item' => 'Wyswietl pojÄcie',
'all_items' => 'Wszystkie pojÄcia',
'search_items' => 'Wyszukaj pojÄcia',
'parent_item_colon' => 'NadrzÄdne ksiÄ
żki',
'not_found' => 'PojÄÄ nie znaleziono',
'not_found_in_trash' => 'Brak usuniÄtych pojÄÄ'
);
$product_args = array(
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'vocabulary' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
'labels' => $labels
);
register_post_type( 'vocabulary', $product_args );
}
All works fine except I cant select any of those custom post types element to insert them into a menu (custom post type section doesn’t show in menu editor).
But… when I change last line
register_post_type( 'vocabularys', $product_args );
suddenly everything works as it should.
The problem is, that I have already few custom post type items, and don’t want to mess with database to change guids and post_type entires for them.
So the final question is – why first one doesn’t work, and the second one does?
After digging more – it seems it has something to do with the order when you add this code. Did clean wp318 installation and putted above code into default 2014 theme. After setting up the database and logging into backend there was no option in custom menu (after creating one).
Now did another install, this time didn’t change anything in the template, logged in, created menu. After that I have added code into functions.php – all did well, with exact same names.
So it looks like there is something blocked in database when custom post type is added in wrong time.