Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wordpress自定义帖子类型不显示在菜单页中_Php_Wordpress_Custom Post Type - Fatal编程技术网

Php wordpress自定义帖子类型不显示在菜单页中

Php wordpress自定义帖子类型不显示在菜单页中,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,我已经注册了一个自定义的帖子类型,想把这个CPT的条目添加到我的菜单中。我有多个管理员角色的用户,但他们只显示在一个特定的用户下——其他用户根本看不到自定义的帖子类型 // functions.php function register_cpt_trainings() { $labels = array( 'name' => _x( 'Trainings', 'Post Type General Name', 'somedomain'

我已经注册了一个自定义的帖子类型,想把这个CPT的条目添加到我的菜单中。我有多个管理员角色的用户,但他们只显示在一个特定的用户下——其他用户根本看不到自定义的帖子类型

// functions.php
function register_cpt_trainings() {

    $labels = array(
        'name'                => _x( 'Trainings', 'Post Type General Name', 'somedomain' ),
        'singular_name'       => _x( 'Training', 'Post Type Singular Name', 'somedomain' ),
        'menu_name'           => __( 'Trainings', 'somedomain' ),
        'parent_item_colon'   => __( 'Eltern Training:', 'somedomain' ),
        'all_items'           => __( 'Alle Trainings', 'somedomain' ),
        'view_item'           => __( 'Training anzeigen', 'somedomain' ),
        'add_new_item'        => __( 'Training hinzufügen', 'somedomain' ),
        'add_new'             => __( 'hinzufügen', 'somedomain' ),
        'edit_item'           => __( 'Training bearbeiten', 'somedomain' ),
        'update_item'         => __( 'Training aktualisieren', 'somedomain' ),
        'search_items'        => __( 'Durchsuche Trainings', 'somedomain' ),
        'not_found'           => __( 'Nicht gefunden', 'somedomain' ),
        'not_found_in_trash'  => __( 'Nicht im Papierkorb gefunden', 'somedomain' ),
    );
    $args = array(
        'label'               => __( 'trainings', 'somedomain' ),
        'description'         => __( 'Trainings', 'somedomain' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', ),
        'taxonomies'          => array( 'category' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => false,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page'
    );
    register_post_type( 'trainings', $args );
}
在设计/菜单中,我希望它们显示在所有管理员用户上,但其他用户只有默认条目“posts”、“page”、“links”和“categories”

我的用户也有“培训”


有什么想法吗?

解决方案:在后端,屏幕顶部有当前管理页面的选项。默认情况下,CPT不会显示在那里,但可以在那里激活


来源:

在你的function.php文件中添加这个
add_action('init','register_cpt_trainings')
@ShravanShrama培训确实会在菜单栏中的所有管理员用户处显示-但是,除了一个用户之外,他们不会在“设计”/“菜单”中显示为所有用户的选项。这可以通过此插件轻松完成不,它不能-因为CPT不会显示。