Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was able to use <?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => false ) ); ?> to create the menu within my theme. Messed around with 'items_wrap' but couldn't get it to display correctly.

I need to add an image and container div into the sub menu ul before the li's. This is the structure I want:

    <ul id="nav">
    <li><a href="#">Page</a>
        <ul>
            <img src="<?php bloginfo('template_directory'); ?>/images/nav_ul_tab.png" class="nav_ul_tab" />
            <div class="nav_spacer">
                <li><a href="#">Sub Page</a></li>
                <li><a href="#">Sub Page</a></li>
                <li><a href="#">Sub Page</a></li>
            </div>
         </ul>
    </li>
   </ul>
share|improve this question

2 Answers 2

We can insert the image via Jquery. Here is the code. Before execute this code make sure JQuery JavaScript should be load in your page.

<script type="text/javascript">
   jQuery(document).ready(function(){
        jQuery("#nav li ul .nav_spacer").before('<img src="<?php bloginfo('template_directory'); ?>/images/nav_ul_tab.png" class="nav_ul_tab" />')
   });
</script>
share|improve this answer

What you want is invalid markup. The only children an ul can have are li. Use CSS instead:

#nav ul
{
    padding-top:    40px; /* Your image size. */
    background:     url(/path/to/your/image/img.png) top center no-repeat transparent;
}
share|improve this answer
    
I have a set width and a height of 100% on that image as a hacked background image to size as the menu drop down grows. I guess its best to just figure out another solution. Thanks for the answer. –  Luke May 4 '11 at 3:16

Your Answer

 
discard

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.