3

Is there any way to disable or remove the "Auto add pages - Automatically add new top-level pages to this menu" functionality via a theme?

I suppose I could hide it with a bit of CSS, but I'd rather do more cleanly if possible.

Many clients click that not realizing what it does and chaos ensues.

  • 1
    There is no filter/action to remove it. You can use CSS/JavaScript for this. – Sumit May 4 '16 at 15:55
2

Since there is no filter to remove this option, your best best to to stick to using CSS by putting the following in your child theme's functions.php:

add_action( 'admin_head', 'wpse_225635_menu_css' );
function wpse_225635_menu_css() {
    global $pagenow;
    if ( $pagenow == 'nav-menus.php' ) {
        ?>
        <style type="text/css">
        .auto-add-pages {
            display: none;
        }
        </style>
        <?php
    }
}
1

As per comments and verifiable in the source:

<dl class="auto-add-pages">
    <dt class="howto"><?php _e( 'Auto add pages' ); ?></dt>
    <dd class="checkbox-input"><input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" id="auto-add-pages" value="1" /> <label for="auto-add-pages"><?php printf( __('Automatically add new top-level pages to this menu' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label></dd>
</dl>

there is no filter to get rid of Auto Add Pages in a clean way. You'll have to use css or javascript.

  • ps: we can get the canonical links on GitHub by pressing 'y' - a trick I learned from @toscho – birgire Sep 18 '16 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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