Navigation Menu links not working, but the bootstrap CSS is working. Can anyone help me in getting the links working? Thank you
<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>
Navigation Menu links not working, but the bootstrap CSS is working. Can anyone help me in getting the links working? Thank you
<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>
Share
Improve this question
edited Apr 25, 2019 at 19:40
RiddleMeThis
3,8078 gold badges22 silver badges30 bronze badges
asked Apr 25, 2019 at 18:47
Santosh KumarSantosh Kumar
32 bronze badges
2 Answers
Reset to default 0Here 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.
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>