WordPress的“自定义帖子类型”未显示在管理员左侧边栏菜单中 [英] Wordpress Custom Post Types doesn't show in admin left sidebar menu

查看:109
本文介绍了WordPress的“自定义帖子类型”未显示在管理员左侧边栏菜单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一种自定义帖子类型存在一个奇怪的问题,该问题未在左侧边栏管理菜单中显示。

I have a weird problem with one of my custom post type that doesn't show in left sidebar admin menu.

我声明了5种自定义帖子类型,但第五种没有显示在左侧菜单中。这里是没有显示的客户帖子类型。我对此进行了大量搜索,但没有成功。

I declared 5 custom post types but the fifth doesn't show in left menu. Here it's the Clients post type that doesn't show. I made a lot of search about this, without success.

非常感谢您的帮助!

    /**
 * Custom Posts Types
 */

add_action('init', 'create_team_post_type');
function create_team_post_type() {
    register_post_type( 'phil_team',
        array(
            'labels' => array(
                'name' => __('Équipe'),
                'singular_name' => __('Individu'),
                'add_new' => __('Ajouter'),
                'add_new_item' => __('Ajouter un individu'),
                'view_item' => __('Voir individu'),
                'edit_item' => __('Modifier individu'),
                'search_items' => __('Rechercher un individu'),
                'not_found' => __('Individu non trouvé'),
                'not_found_in_trash' => __('Individu non trouvé dans la corbeille')
            ),
            'public' => true,
            'hierarchical' => false,
            'menu_position' => 21,
            'rewrite' => array('slug' => 'team'),
            'supports' => array('title', 'editor', 'thumbnail'),
            'show_ui' => true
        )
    );
}

add_action('init', 'create_projects_post_type');
function create_projects_post_type() {
    register_post_type( 'phil_projects',
        array(
            'labels' => array(
                'name' => __('Projets'),
                'singular_name' => __('Projet'),
                'add_new' => __('Ajouter'),
                'add_new_item' => __('Ajouter un projet'),
                'view_item' => __('Voir projet'),
                'edit_item' => __('Modifier projet'),
                'search_items' => __('Rechercher un projet'),
                'not_found' => __('Projet non trouvé'),
                'not_found_in_trash' => __('Projet non trouvé dans la corbeille')
            ),
            'public' => true,
            'menu_position' => 21,
            'query_var' => 'project',
            'rewrite' => array('slug' => 'who-we-help/our-work'),
            'supports' => array('title', 'editor', 'thumbnail'),
            'show_ui' => true
        )
    );

    $set = get_option('post_type_rules_flased_POST-TYPE-NAME-HERE');
    if ($set !== true){
       flush_rewrite_rules(false);
       update_option('post_type_rules_flased_POST-TYPE-NAME-HERE',true);
}
}

add_action('init', 'create_slideshow_post_type');
function create_slideshow_post_type() {
    register_post_type( 'phil_home_slideshow',
        array(
            'labels' => array(
                'name' => __('Slideshow'),
                'singular_name' => __('Image'),
                'add_new' => __('Ajouter'),
                'add_new_item' => __('Ajouter une image'),
                'view_item' => __('Voir image'),
                'edit_item' => __('Modifier image'),
                'search_items' => __('Rechercher une image'),
                'not_found' => __('Image non trouvé'),
                'not_found_in_trash' => __('Image non trouvé dans la corbeille')
            ),
            'public' => true,
            'hierarchical' => false,
            'menu_position' => 21,
            'rewrite' => array('slug' => 'slideshow'),
            'supports' => array('title', 'editor', 'thumbnail'),
            'show_ui' => true
        )
    );
}

add_action('init', 'create_home_boxes_post_type');
function create_home_boxes_post_type() {
    register_post_type( 'phil_home_boxes',
        array(
            'labels' => array(
                'name' => __('Boîtes page d\'accueil'),
                'singular_name' => __('Boîte'),
                'add_new' => __('Ajouter'),
                'add_new_item' => __('Ajouter une boîte'),
                'view_item' => __('Voir boîte'),
                'edit_item' => __('Modifier boîte'),
                'search_items' => __('Rechercher une boîte'),
                'not_found' => __('Boîte non trouvé'),
                'not_found_in_trash' => __('Boîte non trouvé dans la corbeille')
            ),
            'public' => true,
            'hierarchical' => false,
            'menu_position' => 21,
            'supports' => array('title', 'editor', 'thumbnail'),
            'show_ui' => true
        )
    );
}

add_action('init', 'create_clients_post_type');
function create_clients_post_type() {
    register_post_type( 'phil_clients',
        array(
            'labels' => array(
                'name' => __('Clients'),
                'singular_name' => __('Client'),
                'add_new' => __('Ajouter'),
                'add_new_item' => __('Ajouter un client'),
                'view_item' => __('Voir client'),
                'edit_item' => __('Modifier client'),
                'search_items' => __('Rechercher une client'),
                'not_found' => __('Client non trouvé'),
                'not_found_in_trash' => __('Client non trouvé dans la corbeille')
            ),
            'public' => true,
            'show_ui' => true,
            'hierarchical' => false,
            'menu_position' => 21,
            'supports' => array('title', 'editor', 'thumbnail')
        )
    );
}


推荐答案

相同,但未在左侧管理菜单中显示的原因之一是帖子类型名称的长度超过20个字符
功能参考/注册帖子类型

This case does not seem to be the same, but one reason for not showing in the left admin menu is the length of the name of the post type is longer than 20 characters Function Reference/register post type

这篇关于WordPress的“自定义帖子类型”未显示在管理员左侧边栏菜单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆