WordPress自定义帖子类型管理员嵌套菜单(WordPress Custom Post Type Admin Nested Menu)

编程入门 行业动态 更新时间:2024-10-24 00:30:42
WordPress自定义帖子类型管理员嵌套菜单(WordPress Custom Post Type Admin Nested Menu)

我在Wordpress中创建了一些松散相关的自定义帖子类型 - 它们没有直接连接,例如分类,但从UI角度来看,它们应该在管理员端。 两个自定义帖子类型都显示在管理区域中,但它们是顶级项目,我更喜欢将它们分组在主菜单项下,如下所示:

产品(top level item) 所有产品(first custom post type) 产品组(second custom post type)

虽然这两者没有直接关系,但将它们组合在一起以帮助防止管理区域变得杂乱是合乎逻辑的。

我尝试了几种不同的东西,但我确定这是一个我不理解的基本设置。 最新的是add_submenu_page选项,但似乎没有像我预期的那样工作。 以下是代码示例:

add_action('admin_menu', 'create_child_menus'); function create_child_menus() { add_submenu_page('products', 'Product Groups', 'Product Groups', 'manage_options', 'edit.php?post_type=product_groups'); }

关于如何获得包含多个非相关自定义帖子类型的管理项目的顶级分组的任何想法?

I have created a couple of custom post types in Wordpress that are loosely related - they aren't directly connected such as with a taxonomy, but from a UI perspective they should be on the admin side. Both custom post types are showing up in the admin area, however they are top-level items and I'd prefer to have them grouped under a master menu item like so:

Products (top level item) All Products (first custom post type) Product Groups (second custom post type)

While the two aren't directly related, it makes logical sense to group them together to help keep the admin area de-cluttered.

I've tried a couple of different things, but am certain it's a basic setting I'm not understanding. The most recent is the add_submenu_page option, but that doesn't seem to be working as I intended. Here is an example of the code:

add_action('admin_menu', 'create_child_menus'); function create_child_menus() { add_submenu_page('products', 'Product Groups', 'Product Groups', 'manage_options', 'edit.php?post_type=product_groups'); }

Any ideas on how I can get a top-level grouping of admin items that contain multiple, non-related custom post types?

最满意答案

我假设您有“产品”和“product_groups”的自定义帖子类型。

注册“product_groups”帖子类型时,请使用以下参数:

'show_ui' => true, 'show_in_menu' => 'edit.php?post_type=products',

并取消add_submenu_page()

I will assume you have custom posts types for 'products' and 'product_groups'.

When you register your 'product_groups' post type, use the following args:

'show_ui' => true, 'show_in_menu' => 'edit.php?post_type=products',

And do away with add_submenu_page()

更多推荐

本文发布于:2023-07-23 12:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1231662.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   自定义   菜单   管理员   类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!