最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Cannot include custom post item within a menu

programmeradmin0浏览0评论

I'm trying to insert my custom post type within a menu of a theme. This theme actually have a custom post type called st_tours. So when I register my custom post type I do:

$args = array(
    'labels' => $labels,
    'has_archive' => true,
    'public' => true,
    'hierarchical' => false,
    'rewrite'   => array('slug' => 'tour'),
    'show_in_rest' => true,
    'exclude_from_search' => true,
    'show_im_menu' => 'edit.php?post_type=st_tours'
);

register_post_type('tour', $args);

but my custom post type isn't inserted in the menu of the theme, Wordpress define a new menu called Tour.

What I did wrong?

eg:

I'm trying to insert my custom post type within a menu of a theme. This theme actually have a custom post type called st_tours. So when I register my custom post type I do:

$args = array(
    'labels' => $labels,
    'has_archive' => true,
    'public' => true,
    'hierarchical' => false,
    'rewrite'   => array('slug' => 'tour'),
    'show_in_rest' => true,
    'exclude_from_search' => true,
    'show_im_menu' => 'edit.php?post_type=st_tours'
);

register_post_type('tour', $args);

but my custom post type isn't inserted in the menu of the theme, Wordpress define a new menu called Tour.

What I did wrong?

eg:

Share Improve this question asked Feb 5, 2021 at 17:24 sfarzososfarzoso 498 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Here's the problem:

    'show_im_menu' => 'edit.php?post_type=st_tours'

You made a typo, it isn't show_im_menu, it's show_in_menu

发布评论

评论列表(0)

  1. 暂无评论