WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
<div class="menu">
        <li class="page_item page-item-15"><a href="link.html">XXX</a></li>

Where "XXX" I want to put

The reason I want to do it is that I'm coding top menu and I want to display a picture on hover of the link.

It would be like that:

.menu ul li:hover myClass { display:block; }

Example of what effect I am trying to accomplish can be see in top menu here http://www.templatemonster.com/demo/37119.html

I've searched all the template files and it seems that this link is generated somewhere in php file in wp-content folder and I can't find it.

I've solved the problem.

The solution was that I don't need to edit any stuff in wp-includes.I only needed to add parameters in my template file.

In the beggining I had this code in header:

<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary') ); ?>

So I just added 'link_after' => '<div class="one"></div>', after array( and it worked fine.

Thanks you Bainternet :)

share|improve this question
up vote 1 down vote accepted

When using wp_nav_menu you can pass arguments to it which help you style the output, look at:

  • $container Whether to wrap the ul, and what to wrap it with. Allowed tags are div and nav. Use false for no container e.g. container => false .
  • $container_class the class that is applied to the container.
  • $container_id The ID that is applied to the container.
  • $menu_class CSS class to use for the containing div element which forms the default menu, or the ul element when a custom menu is configured in the admin interface.
  • $before Output text before the of the link.
  • $after Output text after the of the link.
  • $link_before Output text before the link text.
  • $link_after Output text after the link text.
  • $items_wrap Whatever to wrap the items with an ul, and how to wrap them with.

So in you case you can use

array( 'link_before' => '<div class="your_class">' , 'link_after' => '</div>');

But if you ask me you can probably do what you want with the classes WordPress prints out anyway.

share|improve this answer
+1 IMHO the last paragraph of the answer is the most important one :) – Michal Mau Feb 27 '12 at 14:38
@Bainternet Could you please tell me which part of nav-menu-template to modify.I'be been searchingm but there are 500lines of code, and not the simple one to me at least. – Tomas Feb 27 '12 at 16:10
@Tomas you missed the point, you don't need to modify anything. edit you question with the code you use to print the menu and i'll show you. Maugly: +1 for catching that :) – Bainternet Feb 27 '12 at 16:34
@Bainternet thanks a lot! Now I got it.I posted my solution in the first post.I'm glad I could do it without editing anything outside my theme :) – Tomas Feb 27 '12 at 19:21
@Tomas Glad it worked for you :) – Bainternet Feb 28 '12 at 18:26

Your Answer


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.