WordPress: How to show a metabox on any admin page?

Deadly 提交于 2019-12-07 08:13:46

问题


I already know how to register metaboxes for Posts, Page, and Custom Post Types, but I would like to register a metabox to be shown on my custom admin page, which is not a post.

My plugin has an "Options Page" in the WordPress Admin – I would like to show metaboxes on this very page.

Is this possible? If yes, how can this be acheived?

I saw in the add_meta_box documentation that one of the possible values for the $post_type parameter is dashboard, however this is not documented anywhere. I guess it would show the metabox on the WordPress Dashboard (the main admin screen when logging-in), but this is not what I need or want.

Edit:

This question is about OptionTree Metaboxes, which uses the standard WordPress Metaboxes. Perhaps there is a better way to accomplish this by using OptionTree differently, or by modifying OptionTree? Please see this related question: How to have more than one "Theme Options" page with OptionTree?


回答1:


if my understanding is right you can do it by following

Here is a Demo plugin that can help you get it working.

This WordPress Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine




回答2:


Never tried but just an idea. In your plugins options page url pass another parameter say post-type and provide any new post type name. Then use this parameter value in add_meta_box() function $post_type = $_GET['post_type'].



来源:https://stackoverflow.com/questions/18394775/wordpress-how-to-show-a-metabox-on-any-admin-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!