Support » Fixing WordPress » Add metabox to the plugin settings page

  • I’m designing my own plugin for WP and want to group bunches of controls in something like metabox in my plugin’s settings page. There is a function called add_meta_box() for it. But it works only with the Write Post, Write Page, and Write Link editing pages, not with the plugin settings page. Is there a way to add metabox to the plugin settings page?

Viewing 5 replies - 1 through 5 (of 5 total)
  • For consistency and future-proofing it might be best to stick with the normal styling provided by the Settings API. However, if you really want to add meta boxes, I do know that add_meta_box() just adds a meta box to a queue which is then output by the do_meta_boxes() function.

    Function Reference/do meta boxes

    This reference is a bit old, but may offer a few useful insights/examples:

    Big Bagel, thanks for your answer!
    I’ve got it working by setting $screen parameter of add_meta_box() to null. This adds metabox to the current screen (get_current_screen()). I’ve also found that proper $screen value should be equal to the “settings_page_” . $menu_slug (fourth parameter of the add_options_page()) value, when adding metabox to your plugin.

    Oleg, interesting hack. Does it still works for you?

    I’m trying but it is not displaying the meta box. The “Screen Options” appear in my page and the meta box appears as if it were present, but nothing shows.

    For testing, I also used $screen / $post_type as profile.php. Same thing, “Screen Options” are there, but nothing…

    The Andrew Ferguson blog seems off-line, hurray to the Internet Archive:

    you can add settings section or setting page. meta boxes can be added to post, page, links and custom post type.




    yes, it works great. I used this method in my WP Posts Filter plug-in. Metabox is just a div with the feature of folding. What I can tell you, is that it is barely a hack, as metabox could be applied in the settings page. It is undocumented though. And I suppose metabox could be applied everywhere, you just need to play with the screen value.

    the reason why I used metabox in my plugin was simple: I needed a container for a bunch of controls and text, and count of these elements could be unlimited. Since that, having blocks with folding feature is much better for UX.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add metabox to the plugin settings page’ is closed to new replies.