0

I'm trying to accomplish two things with a walker for wp_nav_menu:

  1. I would like the unordered list to be <ul id="my_list_id" role="navigation"> instead of <ul id="my_list_id" class="navigation"> (Or maybe both role and class?)
  2. I'd like to wrap the unordered list with <!-googleon: all-> and <!-googleoff: all->

Honestly, the code for a custom walker is tough for me to understand. Any help or guidance is appreciated.

1
  • Welcome to Stack Overflow. You will increase your chances to get a meaningful response here, if you state what you have already tried to solve the problem yourself and post some artifacts (code, etc.) of such attempts.
    – PM 77-1
    Dec 1, 2013 at 23:02

1 Answer 1

0

wp_nav_menu has a option to add classes or other attributes to ul by using items_wrap.

below is the code -

wp_nav_menu( array( 'theme_location' => 'primary-menu','menu'=>'Primary', 'items_wrap' => '<ul id="my-nav" class="navigation" role="navigation">%3$s</ul>'  ) );

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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