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 am trying to add some code before the list items in a sidebar Custom Menu Widget. Maybe I'll add an image, maybe I'll add some text. Not sure yet. But I'm having a hard time trying to figure it out...

In nav-menus.php screen, the name of the menu is "aboutus" and the id is: menu=210.

function custom_menu_widget_aboutus( $args ) {
//if( 'aboutus' == $args['menu'] ) {
if( 210 == $args['menu_id'] ) {
  $args['before'] = 'DO_SOMETHING_BEFORE_LIST_ITEM';
}   
return $args;
}
// wp_nav_menu_{MENUSLUG}_items
add_filter( 'wp_nav_menu_args', 'custom_menu_widget_aboutus' );

I know the hook is working becuse if I remove the IF statement, I'm getting the before args working in "aboutus" menu and in my primary menu and all the other menus I have active (footer, etc). But for some reason I cannot target the sidebar menu "aboutus" or id: "210" specifically by itself.

I've included commented code to show what I've tried already.

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.