0

我创建了多个自定义帖子类型,后端菜单变得混乱,因为我有 20 种帖子类型。

我想把我所有的帖子类型放在一个管理菜单项下(称为“所有帖子类型”),我得到了这个工作,但我只有“所有 [自定义帖子类型]”的选项

在此处输入图像描述

我希望菜单项“Recepten”与taxmonies 和“add Recept”按钮一样,如果你将“show_in_menu”设置为true。

在此处输入图像描述

创建自定义帖子类型“Recepten”的代码是这样的

function recepten_post_type()
{

    $labels = array(
        'name'                  => _x('Recepten', 'Post Type General Name', 'jointswp'),
        'singular_name'         => _x('Recept', 'Post Type Singular Name', 'jointswp'),
        'menu_name'             => __('Recepten', 'jointswp'),
        'name_admin_bar'        => __('Recepten', 'jointswp'),
        'archives'              => __('Recepten bibliotheek', 'jointswp'),
        'attributes'            => __('Recept Attributen', 'jointswp'),
        'parent_item_colon'     => __('Parent Item:', 'jointswp'),
        'all_items'             => __('Alle Recepten', 'jointswp'),
        'add_new_item'          => __('Voeg Recept toe', 'jointswp'),
        'add_new'               => __('Add New', 'jointswp'),
        'new_item'              => __('Nieuwe Recept', 'jointswp'),
        'edit_item'             => __('Bewerk Recept', 'jointswp'),
        'update_item'           => __('Update Recept', 'jointswp'),
        'view_item'             => __('Bekijk Recept', 'jointswp'),
        'view_items'            => __('Bekijk Recepten', 'jointswp'),
        'search_items'          => __('Zoek Recept', 'jointswp'),
        'not_found'             => __('Not found', 'jointswp'),
        'not_found_in_trash'    => __('Not found in Trash', 'jointswp'),
        'featured_image'        => __('Featured Image', 'jointswp'),
        'set_featured_image'    => __('Set featured image', 'jointswp'),
        'remove_featured_image' => __('Remove featured image', 'jointswp'),
        'use_featured_image'    => __('Use as featured image', 'jointswp'),
        'insert_into_item'      => __('Voeg toe aan Recept', 'jointswp'),
        'uploaded_to_this_item' => __('Uploaded to this item', 'jointswp'),
        'items_list'            => __('Items list', 'jointswp'),
        'items_list_navigation' => __('Items list navigation', 'jointswp'),
        'filter_items_list'     => __('Filter items list', 'jointswp'),
    );
    $args = array(
        'label'                 => __('Recepten', 'jointswp'),
        'description'           => __('Recepten Verstege', 'jointswp'),
        'labels'                => $labels,
        'supports'              => array('title', 'thumbnail', 'page-attributes'),
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => 'post-types',
        'show_in_rest'          => true,
        'menu_position'         => 11,
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'page',
        'rewrite'     => array(
            'slug'       => 'recepten',
        )
    );
    register_post_type('recept', $args);
}
add_action('init', 'recepten_post_type', 0);

我如何创建我的自定义分类是这样的

function create_recipe_custom_taxonomy()
{

    $labels = array(
        'name' => _x('Recept Filter', 'taxonomy general name'),
        'singular_name' => _x('Filter', 'taxonomy singular name'),
        'search_items' =>  __('Zoek filter'),
        'all_items' => __('Alle Filters'),
        'parent_item' => __('HoofdFilter'),
        'parent_item_colon' => __('HoofdFilter:'),
        'edit_item' => __('Edit Filter'),
        'update_item' => __('Update Filter'),
        'add_new_item' => __('Nieuwe Filter'),
        'new_item_name' => __('Nieuwe Filter'),
        'menu_name' => __('Filters'),
    );

    register_taxonomy('recipe-filters', array('recept'), array(
        'hierarchical'      => true,
        'labels'            =>  $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'show_in_menu'      => 'post-types',
        'rewrite'           => array('slug' => 'filter'),
    ));
}
add_action('init', 'create_recipe_custom_taxonomy', 1);

我希望有一个人可以帮助我!

4

0 回答 0