0
votes

I use Simple Custom Post Types plugin to create new Custom Post Types and I use Simple Taxonomy plugin to create new Taxonomy, but when I would like to create or update a new post wordpress doesn't display me the custom type or taxonomy that I have created before.

This is my code :

add_action( 'init', 'register_my_cpt_video', 10 );

function register_my_cpt_video() {
    register_post_type( "video", array (
        'labels' => 
        array (
            'name' => 'Vidéos',
            'singular_name' => 'Vidéo',
            'add_new' => 'Ajouter',
            'add_new_item' => 'Ajouter une nouvelle vidéo',
            'edit_item' => 'Modifier la vidéo',
            'new_item' => 'Nouvelle vidéo',
            'view_item' => 'Voir la vidéo',
            'search_items' => 'Chercher une vidéo',
            'not_found' => 'Aucune vidéo trouvée',
            'not_found_in_trash' => 'Aucune vidéo trouvée dans la corbeille',
            'parent_item_colon' => 'Vidéo parente:',
        ),
        'description' => '',
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'map_meta_cap' => true,
        'capability_type' => 'post',
        'public' => true,
        'hierarchical' => false,
        'rewrite' => 
        array (
            'slug' => 'video',
            'with_front' => true,
            'pages' => true,
            'feeds' => true,
        ),
        'has_archive' => true,
        'query_var' => 'video',
        'supports' => 
        array (
            0 => 'title',
            1 => 'editor',
            2 => 'thumbnail',
            3 => 'comments',
        ),
        'taxonomies' => 
        array (
            0 => 'category_video',
        ),
        'show_ui' => true,
        'menu_position' => 30,
        'menu_icon' => false,
        'can_export' => true,
        'show_in_nav_menus' => true,
        'show_in_menu' => false,
    ) );
}

Any idea? Thanks in advance.

2

2 Answers

0
votes

The last element (show_in_menu) is set to false, set it to true ( https://codex.wordpress.org/Function_Reference/register_post_type#show_in_menu )

0
votes

I go about it a little differently, by using this code below in the functions.php file (well actually as an include to keep it neat). This code creates a "sign" custom post type and a custom category for the "signs" (This was for a local sign shop). Hope you can reference this and it helps....

<?php       
//Custom Post Type Code
function my_custom_post_types(){
register_post_type('sign', 
    array(  'label' => 'Sign',
            'description' => 'Sign',
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'has_archive' => true,
            'rewrite' => array('slug' => 'signs'),
            'query_var' => true,
            'publicly_queryable' => true,
            'supports' => array('title','editor', 'excerpt'),   
            'taxonomies' => array('signcategory'),
            'menu_icon'=> 'dashicons-star-filled',          
            'labels' => array (
                          'name' => 'Signs',
                          'singular_name' => 'Sign',
                          'menu_name' => 'Signs',
                          'add_new' => 'Add Sign',
                          'add_new_item' => 'Add Sign',
                          'edit' => 'Edit',
                          'edit_item' => 'Edit Sign',
                          'new_item' => 'New Sign',
                          'view' => 'View Sign',
                          'view_item' => 'View Sign',
                          'search_items' => 'Search Signs',
                          'not_found' => 'No Signs Found',
                          'not_found_in_trash' => 'No Sign Found in Trash',
                          'parent' => 'Parent Sign',
                                ),
                        )
                );          

}       
add_action('init', 'my_custom_post_types'); 

//Custom Taxonomy Code (For sign CPT)
register_taxonomy('signcategory',
    array ( 0 => 'signcategory',),
    array( 'hierarchical' => true, 
            'label' => 'Sign Type',
            'show_ui' => true,
            'query_var' => true,
            'rewrite' => true,
            'show_in_nav_menus' => true,
            'show_admin_column' => true,                
            'singular_label' => 'Menu'
        ) 
    );  
?>