Adding Custom Meta Boxes

Hi-

I’m trying to figure out how to add a custom meta box to admin pages other than the post, custom post type, and page write ones. I am doing those successfully using the instructions from WP – http://codex.wordpress.org/Function_Reference/add_meta_box

I’d like to be able to addmeta boxes to any screen, to provide support info for my clients. For instance, On the Broken Link Checker page that lists all asite’s bad links, I’d like to add a custom meta box. I’m hoping for a general solution that will work beyond that case, though, both in plug-ins and default WP pages.

The WP docs say to use this function:

add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );

Where I’m hung up is what to use for the fourth parameter, $post_type, if not ‘post’, ‘page’, or the custom post type slug.

Can anyone help?

Thanks,

Kim

  • cruxwireweb
    • WPMU DEV Initiate

    Hi Patrick-

    Thanks for checking in. Actually, no, my question didn’t get answered, and I still would love to know the answer.

    The resources Tom pointed me to give a bunch of code to create custom metaboxes. I can do that already. What I can’t do is place those metaboxes on any page other than post, page, custom post type, link and attachment edit screens.

    The WP documentation for this gives this function:

    <?php add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args ); ?>

    As far as I can tell, the $post_type parameter is the only place to specify which page a custom meta box appears. The docs say this about the parameter:

    $post_type

    (string) (required) The type of Write screen on which to show the edit screen section (‘post’, ‘page’, ‘link’, ‘attachment’ or ‘custom_post_type’ where custom_post_type is the custom post type slug)

    But I want to be able to place custom meta boxes on other pages, as in the example I gave in my question.

    Thanks,

    Kim

    PS – Tom mentioned custom field types in his response, and it is indeed good info, but just to be clear, custom fields have nothing to do with my question.

  • aecnu
    • WP Unicorn

    Greetings cruxwireweb,

    Just checking if this issue was eventually resolved in another thread? Or by yourself separately to us? Or by us over email with you? Or using our live support?

    If so, no need to reply, that’s great news.

    If not, or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the ‘Mark as Not Resolved (re-open)’ box below the post area (or else we’ll miss it!)

    Otherwise, happy days, glad you got it sorted :slight_smile:

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

  • Aaron
    • Ex Staff

    The wp meta box api only works on post edit pages and the dashboard. Inserting content on other pages you have to handle some other way. Have you though about adding custom help content to the dropdowns? Not too hard, see our custom help content plugin for an idea.