How to add div to top menu item

<div class="menu">
    <ul>
        <li class="page_item page-item-15"><a href="link.html">XXX</a></li>
    </ul>
</div>

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.

Read More

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 🙂

Related posts

Leave a Reply

1 comment

  1. 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.