PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 8, 2022

[FIXED] How would I add a title before the ul using wp_nav_menu?

 November 08, 2022     menu, wordpress     No comments   

Issue

I need to add a title to my menu, which is being built by wp_nav_menu...something like this:

<div class="container">
  <div class="title">My Menu Title</div>
  <ul class="menu">
    <li class="item"><a href="#">Item 1</a></li>
    <li class="item"><a href="#">Item 2</a></li>
    <li class="item"><a href="#">Item 3</a></li>
  </ul>
</div>

I find it strange that this isn't included by default :s


Solution

This should work for you!

wp_nav_menu(
  array(
    'items_wrap' => '<div class="title">Your menu title</div><ul class="%2$s">%3$s</ul>'
  )
);


Answered By - Anonymous
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing