wp-bootstrap / wp-bootstrap-navwalker

A custom WordPress nav walker class to fully implement the Twitter Bootstrap 4.0+ navigation style (v3-branch available for Bootstrap 3) in a custom theme using the WordPress built in menu manager.
https://wp-bootstrap.github.io/wp-bootstrap-navwalker/
GNU General Public License v3.0
3.37k stars 1.94k forks source link

add brand for the first element #5

Closed thetom88 closed 11 years ago

thetom88 commented 11 years ago

Hello and thank you for your great custom navbar, it helped me a lot. I'm just wondering if it's possible to add the brand tag for the first element. How can i do that?

SideQuestDIY commented 11 years ago

The way the script is setup its pretty simple.

Since the menu wrappers are outside of the navwalker, all you have to do is add the brand anchor right before the menu declaration.

Here is an example with the brand:

<div class="navbar navbar-fixed-top">
  <div class="navbar-inner">
    <a class="brand" href="#">My Brand</a>
    <?php 
        wp_nav_menu( array(
            //'sort_column' => 'menu_order',
            'menu' => 'header_menu',
            'depth' => 2,
            'container'  => false,
            'menu_class'     => 'nav',
            'walker' => new twitter_bootstrap_nav_walker())
        );
    ?>
  </div>
</div>
thetom88 commented 11 years ago

Thank you for your fast answer! Yes, that's the first thing i've tried, but if i try to add a dropdown on the brand item the layout of the navbar becomes a mess. Could it be better if i add the "brand" class via jquery at the first element of the list? Thank you again for your work!

Il 04/02/2013 16:39, Edward McIntyre ha scritto:

The way the script is setup its pretty simple.

Since the menu wrappers are outside of the navwalker, all you have to do is add the brand anchor right before the menu declaration.

Here is an example with the brand:

— Reply to this email directly or view it on GitHub https://github.com/twittem/wp-bootstrap-navwalker/issues/5#issuecomment-13082382.

SideQuestDIY commented 11 years ago

If you are trying to make a dropdown that looks like the "brand" class I would recommend simply styling the first <li> element with css to look like the "brand" class. That way you have control over how its displayed without errors as you will have to tweek the css anyway.

Depending on your menu structure you can select the first elemnet with somthing like this:

.navbar .nav > li:first-child { }