如何在不将其添加到菜单中的情况下添加 WordPress 管理页面? [英] How do you add a WordPress admin page without adding it to the menu?

查看:33
本文介绍了如何在不将其添加到菜单中的情况下添加 WordPress 管理页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 WordPress 插件,我想要一个无法通过子菜单访问的编辑项目页面(因为这样就不会指定项目).

I'm building a WordPress plugin and I'd like to have an edit-item page that can't be reached via the submenu (because then the item wouldn't be specified).

此资源 (http://codex.wordpress.org/Adding_Administration_Menus) 展示了如何关联具有功能的管理页面,但不知道如何在不将其添加为菜单项的情况下执行此操作.

This resource (http://codex.wordpress.org/Adding_Administration_Menus) shows how to associate an admin page with a function, but not how to do so without adding it as a menu item.

这能做到吗?

谢谢!

推荐答案

是的,这可以做到(嗯,从技术上讲,这更像是注册整个事情,然后稍后删除菜单项),但它只会最容易(我认为)检查 $_GET 超级全局中的参数以指示用户希望编辑特定项目.

Yes, this can be done (well, technically, it would be more like registering the whole thing and then removing the menu item later), but It would just be easiest (I think) to check for parameters in the $_GET super-global to indicate that the user wishes to edit a specific item.

例如,您可以有一个页面列出要编辑的项目,单击编辑"只会将项目的 ID 添加到当前 URL(查询字符串).

For example, you could have a page that lists items to edit, and clicking 'edit' only adds the item's ID to the current URL(query-string).

在显示此页面的函数中,如果定义了 ID,则为他们提供编辑该项目的页面.

In the function that displays this page, if ID is defined, give them the page to edit that item.

否则,给他们列表视图.这就是帖子、页面和其他自定义帖子类型的工作方式.

Otherwise, give them the list view. That's how posts, pages, and other custom post types do it.

这篇关于如何在不将其添加到菜单中的情况下添加 WordPress 管理页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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