WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently developing a new WordPress theme employed on the basis of twitters bootstrap build.

To use the menu Custom Navbar, I've followed the instructions of goodandorgreat.


My problem now is that menu items with submenus are also clickable.

That should not be so. What could I do here?

header.php Setup:

<div class="navbar">
<div class="navbar-inner">
    <div class="container">

        <!-- Optional: Button zum Menü einklappen auf Mobilgeräten, benötigt responsive.css -->
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        <!-- Ende Button -->

        <div class="nav-collapse">

        $args = array(
            'theme_location' => 'top-bar',
            'menu' => 'main-menu', 
            'container_class' => 'nav-collapse',
            'menu_class'     => 'nav',
            'menu_id' => 'main-menu',
            'walker'     => new Bootstrap_Walker_Nav_Menu()




I dont want handle that with entrie url's like "#".

share|improve this question
up vote 1 down vote accepted

I am admittedly out on a limb here because to test this I'd have to install your code and create some menus to test it with, but...

Look in the Bootstrap_Walker_Nav_Menu code. Find this:

$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= ($args->has_children) ? ' <b class="caret"></b></a>' : '</a>';
$item_output .= $args->after;

I believe that what you want is to wrap the code that creates the anchors in a conditional like:

if (!$args->has_children) {
    $item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= ($args->has_children) ? ' <b class="caret"></b>' : '';
if (!$args->has_children) {
    $item_output .= '</a>';
$item_output .= $args->after;
share|improve this answer
Looking at the source of the page, this seem to be doing what I thought that you wanted. That is, only the lowest level, childless list items have anchor tags. Your theme's CSS seems to need those anchors for the dropdowns to work. You will need to rewrite that CSS. If I have misunderstood, please edit your question to clarify. – s_ha_dum Nov 3 '12 at 21:18
Thank you .. :-) – hazelnut Nov 4 '12 at 14:43

Your Answer


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.