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.

  • 1
    Digged even a little more... It looks like some strange bug, or perhaps it's in purpose - if the custom post type menu entires are invisible - they are hidden in screen options for that user. It seems WP somehow hides it when it is added in wrong moment or after updating to 3.8.1 what was a problem in my case. – Marcin Bobowski Mar 9 '14 at 6:55
  • Have you tried to change the rewrite url as well? – kaiser Mar 9 '14 at 12:36
  • 1
    No, only register post type first argument. But in database it seems somehow 3.8.1 puts into hidden custom post types. Bug is reported to core as it looks like non user friendly solution. Same problem happens when you update. But to give you a hint about the solution - custom post type do not disappear cpempletly - it is hidden in "screen options" somehow. – Marcin Bobowski Mar 9 '14 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.