0

Navigation Menu links not working, but the bootstrap CSS is working. Can anyone help me in getting the links working? Thank youenter image description here

<ul class="navbar-nav mr-auto">            
      <?php
      wp_nav_menu(array(
        'theme_location' => 'primary',
        'before' => '<class="nav-item active">',      
        'menu_class' =>'navbar-nav mr-auto',
        'link_before' =>'<a class="nav-link" href="#">',      
        'link_after' =>'<span class="sr-only">(current)</span></a>', 
        'container' => false, 
        'items_wrap' => '%3$s'
      ));
      ?>
    </ul>
0

Here are a couple things I noticed.

You don't want to include the <a> inside of link_before or link_after, you will get 2 links if you do that. You also don't need the <ul>. Instead I think you want something like this...

<?php
    wp_nav_menu(array(
        'theme_location' => 'primary',
        'before' => '<class="nav-item active">',      
        'menu_class' =>'navbar-nav mr-auto',
        'link_before' =>'<span class="nav-link">',      
        'link_after' =>'</span>', 
        'container' => false, 
        'items_wrap' => '%3$s'
    ));
?>

You should read more about wp_nav_menu.

0

The problem you're using dead link (#) in link_before. You can test removing "#" from link_before

    <ul class="navbar-nav mr-auto">            
          <?php
          wp_nav_menu(array(
            'theme_location' => 'headerMenuLocation',
            'before' => '<class="nav-item active">',      
            'menu_class' =>'navbar-nav mr-auto',
            // 'link_before' =>'<a class="nav-link" href="#">',
                                  //problem is here {href="#"}     
            // 'link_after' =>'<span class="sr-only">(current)</span></a>', 
            'container' => false, 
            'items_wrap' => '%3$s'
          ));
          ?>
        </ul>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.