5

I'm building a plugin which extends Wordpress's Custom Menus, and I would like to put the new options for it on the current custom menu page, but I can't work out how to add new sections to it.

I have tried to add a section to 'nav-menus.php', but that doesn't seem to have an effect:

add_action('admin_init', 'menu_initialize_theme_options'); 

function menu_initialize_theme_options() {  
    add_settings_section(  
        'menu_settings_section',
        'menu Options',                  
        'menu_general_options_callback',
        'nav-menus.php'                            
    );  

    add_settings_field(  
        'test_field',                        
        'Test',                             
        'menu_test_field_callback',  
        'nav-menus.php',                            
        'menu_settings_section',         
        array(                             
            'Activate this setting to TEST.'  
        )  
    );

    register_setting(  
        'nav-menus.php',  
        'test_field'  
    );
}

function menu_test_field_callback($args) {  
    $html = '<input type="checkbox" id="test_field" name="test_field" value="1" ' . checked(1, get_option('test_field'), false) . '/>';
    $html .= '<label for="test_field"> '  . $args[0] . '</label>';  
   echo $html;  
}

How would I add sections to this page?

I would really like to be able to edit the current menu options inside nav-menus.php as well (to add more fields to each menu item), is there a I can do that?

2
  • Are you trying to add new metaboxes similar to the "Theme Locations", "Custom Links", "Posts" ones?
    – s_ha_dum
    Dec 16, 2012 at 17:06
  • yep, exactly, but can't work out how to get them onto that page?
    – JohnCH
    Dec 17, 2012 at 23:45

1 Answer 1

2
add_meta_box( 'metabox-id', 'metabox-title', 'box-callback', 'nav-menus', 'side', 'low' );

Makeup the first and second parameter. The third parameter needs to be your callback function name for creating the box content. The fourth parameter is the key for getting the box on that "nav-menu" page. The sixth can be 'high', 'core', 'default' or 'low'.

http://codex.wordpress.org/Function_Reference/add_meta_box

1
  • that looks perfect thank you, the main bit I was missing was the correct slug ('nav-menus') for the page :) I'll try it out tomorrow
    – JohnCH
    Dec 19, 2012 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.