Support » Plugins » Hacks » add_settings_section() order

  • Resolved Dark Roast


    I made on a custom theme for a client. For this theme I created a settingspage so my client could edit some variables to his liking. Works like i want it.

    For this same site I created a Custom Post Type as a plugin. I need the client to be able to edit some variables for this custom post type aswell. So I like my plugin to add an other settings section to my settingspage. I’m using this code in my plugin:

    function dr_issue_settings_init() {
    		'dr_issue_section', //$id
    		__( 'Issue settings' ), //title
    		'dr_issue_section_callback', //callback
    		'mytheme_settings' // page
    add_action( 'admin_init', 'dr_issue_settings_init' );

    The problem is; this section appears before the theme settings I created before.
    In the global $wp_settings_sections this plugin section is the first value of the array, before the theme section.

    How can I make my plugin section be underneath the theme section?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    All other things being equal, plugins load before themes, so your plugin section is added before the theme’s sections. Make things unequal by adding a late priority number to your add_action() call so that your callback runs after the theme sections have already been added.

    The default priority is 10, so anything higher/later than 10 should work, such as
    add_action( 'admin_init', 'dr_issue_settings_init', 20 );

    Thread Starter Dark Roast


    Thanx a lot. It indeed was the priority.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_settings_section() order’ is closed to new replies.