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 need help for my custom Wordpress Layout. It should look like this (HTML):

<div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav">
        <li>
             <a href="#about">About</a>
        </li>
        <li>
             <a href="#services">Services</a>
        </li>
        <li>
             <a href="#contact">Contact</a>
        </li>
    </ul>
</div>

In Wordpress:

<div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul>
        <li class="page_item page-item-2"><a href="http://127.0.0.1/wordpress/?page_id=2">Test/Site</a></li>
    </ul>
</div>

My Code:

<?php 
   wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'collapse navbar-collapse navbar-ex1-collapse' ) ); 
?>
share|improve this question
    
Have you defined a menu for the primary menu location? If not, WP will default to wp_page_menu() which will not use the same menu_class parameter. –  helgatheviking Jan 30 at 13:24

1 Answer 1

Menu class is nav navbar-nav not collapse navbar-collapse navbar-ex1-collapse.

wp_nav_menu(array('theme_location' => 'primary', 'menu_class' => 'nav navbar-nav')); 
share|improve this answer
    
Doesn't work. <div class="collapse navbar-collapse navbar-ex1-collapse"> <div class="nav navbar-nav"><ul><li class="page_item page-item-2"><a href="http://127.0.0.1/wordpress/?page_id=2">Example</a></li></ul></div> </div> Ul must have class="nav navbar-nav" –  Nils Jan 30 at 13:09
    
<div class="collapse navbar-collapse navbar-ex1-collapse"> <?php wp_nav_menu( array('theme_location' => 'primary', 'menu_class' => 'nav navbar-nav')); ?> </div> –  Win More Jan 30 at 13:13
    
not woking. Your code set the div class, not the ul class. Self result. <div class="collapse navbar-collapse navbar-ex1-collapse"> <div class="nav navbar-nav"><ul><li class="page_item page-item-2"><a href="http://127.0.0.1/wordpress/?page_id=2">Example</a></li></ul></div> </div> –  Nils Jan 30 at 13:16
1  
<div class="collapse navbar-collapse navbar-ex1-collapse"> <?php $args = array( 'theme_location' => '', 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="nav navbar-na">%3$s</ul>', 'depth' => 0, 'walker' => '' ); wp_nav_menu( $args ); ?> </div> –  Win More Jan 30 at 13:25
2  
In the future, please update your answer in response to comments, especially if you're modifying code samples. It's a lot easier to read when you have the luxury of using line breaks. –  Pat J Jan 30 at 14:08

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.