Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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';
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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