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

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 );
  • 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. Commented Jun 7, 2016 at 15:42

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

  • 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
    Commented Nov 29, 2011 at 14:15

Your Answer

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

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