I created html template based on bootstrap css and am trying to create wordpress theme from it now.
Created my own menu function for it, which basically just sets default config for wp_nav_menu function:
functions.php
<?php
function pin_menu(){
$defaults = array(
'theme_location' => 'primary',
'menu' => 'nav-menu',
'container' => false,
'container_class' => '',
'container_id' => '',
'menu_class' => 'nav-collapse collapse pull-right',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => false,
'depth' => 1,
'walker' => ''
);
return wp_nav_menu( $defaults );
}
?>
All this prints out this html:
<div class="nav-collapse collapse pull-right">
<ul>
<li class="page_item page-item-5"><a href="http://localhost/page5/">page5</a></li>
<li class="page_item page-item-7"><a href="http://localhost/page7/">page5</a></li>
<li class="page_item page-item-15"><a href="http://localhost/page15/">page15</a></li>
<li class="page_item page-item-17"><a href="http://localhost/page17/">page17</a></li>
<li class="page_item page-item-19"><a href="http://localhost/page19/">page19</a></li>
</ul>
</div>
I cant understand why though.
If i read the codex: http://codex.wordpress.org/Function_Reference/wp_nav_menu
Then i have set container to false... yet the code prints out div with the classes i have put for menu_class.
It wraps links with ul, even though i have set items_wrap to false.
This is not what i want though. I actually like this printout but i really cant understand it. And i also would like this ul, that wraps menu items to have certain class..
But when i set items_wrap to <ul class="nav">%3$s</ul>
then nothing changes...
What would be correct config if i want this:
<div class="nav-collapse collapse pull-right">
<ul class="nav">
<li class="page_item page-item-5"><a href="http://localhost/page5/">page5</a></li>
<li class="page_item page-item-7"><a href="http://localhost/page7/">page5</a></li>
<li class="page_item page-item-15"><a href="http://localhost/page15/">page15</a></li>
<li class="page_item page-item-17"><a href="http://localhost/page17/">page17</a></li>
<li class="page_item page-item-19"><a href="http://localhost/page19/">page19</a></li>
</ul>
</div>
Thanks Alan
Edit: Codex also says, that if you want to remove ul wrapping you need to do something like :
<?php wp_nav_menu( array( 'items_wrap' => '%3$s' ) ); ?>
Sorry, but setting items_wrap does not change anything as far as i can see.
Edit2: OK, it seems to be matter of adding too many stats i guess. If i do exactly this:
<?php wp_nav_menu( array( 'items_wrap' => '%3$s' ) ); ?>
Then it works, but other stuff is not how i want. So i guess, i have to set minimal amount of settings, which works.
Edit3: Apparently different settings conflict themselves somewhere... I got what i wanted when i changed my settings to this:
<?php
function pin_menu(){
$settings = array(
'container' => 'div',
'container_class' => 'nav-collapse collapse pull-right',
'container_id' => '',
'menu_class' => '',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul class="nav">%3$s</ul>',
'depth' => 1,
'walker' => ''
);
return wp_nav_menu( $settings );
}
?>