Forums

Add metabox to the plugin settings page (3 posts)

  1. Oleg
    Member
    Posted 3 months ago #

    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?

  2. Big Bagel
    Member
    Posted 3 months ago #

    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:

    http://andrewferguson.net/tag/do_meta_boxes/

  3. Oleg
    Member
    Posted 3 months ago #

    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.

Reply

You must log in to post.

About this Topic