Currently i am using this code to output menu display :

    'theme_location' => 'songs-category',
    'container' => false, 
    'menu_id' => 'nav',
    'menu_class' => '',
    'items_wrap' => '<ul id="nav"><li class="active"><a href="#" data-slug="4,5,6,7,8,9" class="xyz">All</a></li>%3$s</ul>'

getting output:

<ul id="nav">
    <li class="active"><a href="http://domain.com/" title="All">All</a></li>
    <li><a href="http://domain.com/category/category1/">category1</a></li>
    <li><a href="http://domain.com/category/category2/">category2</a></li>
    <li><a href="http://domain.com/category/category3/">category3</a></li>
    <li><a href="http://domain.com/category/category4/">category4</a></li>
    <li><a href="http://domain.com/category/category5/">category5</a></li>
    <li><a href="http://domain.com/category/category6/">category6</a></li>
    <li><a href="http://domain.com/category/category7/">category7</a></li>
    <li><a href="http://domain.com/category/category8/">category8</a></li>
    <li><a href="http://domain.com/category/category9/">category9</a></li>

but need output like this :

<ul id="nav">
  <li><a href="#" data-slug="4,5,6,7,8,9,10,11,12,13,14,15" class="xyz">All</a></li>     
  <li><a href="#" data-slug="10" class="xyz">category1</a></li>
  <li><a href="#" data-slug="12" class="xyz">category2</a></li>
  <li><a href="#" data-slug="15" class="xyz">category3</a></li>
  <li><a href="#" data-slug="9" class="xyz">category4</a></li>
  <li><a href="#" data-slug="4" class="xyz">category5</a></li>
  <li><a href="#" data-slug="11" class="xyz">category6</a></li>
  <li><a href="#" data-slug="13" class="xyz">category7</a></li>
  <li><a href="#" data-slug="8" class="xyz">category8</a></li>
  <li><a href="#" data-slug="7" class="xyz">category9</a></li>

I don't know how to achieve this.

  • What output do you have now?
    – Max Yudin
    Mar 1, 2017 at 12:39

2 Answers 2


You will have to use a custom Walker for your menu. Here is the page in the codex that explains it:


and here:


Hope that helps.


You can do a walker or you can do a custom output getting only what you need using the nav_menu_items function:

// Get wordpress menu and do a custom output
$getMenu = wp_get_nav_menu_items( 'menu1'); // Where menu1 can be ID, slug or title
foreach($getMenu as $item){
   echo '<li><a href="' . $item->url . '">' . $item->title . '</a></li>';

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.