WordPress无法识别自定义帖子类型和分类


Wordpress doesn't recognize the custom post type and taxonomy?

我使用简单的自定义帖子类型插件来创建新的自定义帖子类型,我使用简单的分类插件来创建新的分类法,但是当我想创建或更新新的帖子时,wordpress不会向我显示我以前创建的自定义类型或分类法。

这是我的代码:

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,
    ) );
}

知道吗?提前谢谢。

最后一个元素 (show_in_menu) 设置为 false,将其设置为 true ( https://codex.wordpress.org/Function_Reference/register_post_type#show_in_menu )

我的做法略有不同,通过在函数.php文件中使用下面的代码(实际上作为一个包含以保持整洁)。此代码为"标志"创建自定义帖子类型和自定义类别(这是针对本地标牌商店的)。希望你能参考这个,它有帮助。

<?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'
        ) 
    );  
?>