2

I want to remove certain input fields on the admin screen for nav-menus for specific menu positions. I've used filters to filter front-end output but not for admin output. Is there a filter available for this purpose?

For example, I want to remove the option to add a title attribute to menu items, only if the menu is used in 'position-x'.

Filters such as nav_menu_link_attributes and wp_nav_menu_args all seem to be to filter the front end output.

3

These fields are created in Walker_Nav_Menu_Edit::start_el(). To change or to remove them, create a custom walker (example for another walker) that extends Walker_Nav_Menu_Edit and uses other or less fields.

Then filter wp_edit_nav_menu_walker and return the class name of your walker.

Pseudo-code:

class Walker_Nav_Menu_Edit_Simple extends Walker_Nav_Menu_Edit {
    public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) 
    { /* Magic here. */}
}

add_filter( 'wp_edit_nav_menu_walker', function() {
    return 'Walker_Nav_Menu_Edit_Simple';
});

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.