1

I'm looking for a way to set the default "Automatically add new top-level pages" to be checked when creating a new menu. I haven't been able to find anything on this - any help you could give me? Thanks!

2 Answers 2

3
<?php
add_action( 'wp_create_nav_menu', 'PREFIX_nav_menu_auto_add_by_default' );
function PREFIX_nav_menu_auto_add_by_default( $id ) {
    $options = (array) get_option( 'nav_menu_options' );
    if ( ! isset( $options['auto_add'] ) ) {
        $options['auto_add'] = array();
    }
    $options['auto_add'][] = $id;
    update_option( 'nav_menu_options', $options );
}
1
  • Just want to clarify draebb's answer '$id' is the menu id that we want the top level pages to be added to automatically. So if we want to get the menu $menu_obj = wp_get_nav_menu_object( $menu_name ); and then $menu_id = $menu_obj->term_id; // yes, the menu is a taxonomy. Jun 7, 2016 at 15:42
0

When you create menu check there's a check box "Automatically add new top-level pages " just check it and save

1
  • Hi - this is more to have this option checked by default instead of having to check it off each time (for client work). Little miffed on where this is stored/if we can edit that. Thanks!
    – Zach
    Nov 29, 2011 at 14:15

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.