4
votes

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?

2
Check this.brasofilo
@brasofilo thanks for the link! But using this method I'm not sure how would I save the metabox settings nor to what post ID it will be attached? How could I recover the "post meta" without an ID using get_post_meta()? Thanks!Community
@usernotfound check my answer below, and let me know about itJothi Kannan
@JothiKannan thank you for your answer, for the past 24 hours I tried to make it work using the code linked, without success. Again your demo plugin (which is quit old and use deprecated methods) succeed at showing visual meta boxes which is nothing more than some DIVs with appropriate JS enqueuing, but when you actually need to have a real meta-box that do something and make use of the first parameter in the callback func (which is the current post ID) then the callback fails. Adding a die('enters here'); in the callback shows it's never called... I have WP_DEBUG ON and no error.Community

2 Answers

2
votes

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

0
votes

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'].