Closed Danial-Pervaiz closed 7 years ago
you need to edit bootstrap_navwalker.php ( lines 80 -94 )
$atts = array();
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['class'] = 'nav-link'; // class for anchor tag
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
$atts['href'] = ! empty( $item->url ) ? $item->url : ''; // I have added links for items that has children
$atts['data-toggle'] = ''; // removed data-toggle to enable show 2-nd level on hover
$atts['class'] = 'nav-link dropdown-toggle'; //class for dropdown anchor tag
$atts['aria-haspopup'] = 'true';
} else {
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
}
We recently updated to 2.0.5, so you may want to update and the lines you need to modify may have changed. With that said, I will leave this open, as we may be able to make the walker more filterable to modify classes as needed.
In a future version of the walker assigning classes is a lot easier. I believe this fix still works with the current master branch so long as you adjust the line numbers to where this code is now found.
Since this fix work, and will be possible in future version, I am going to close this ticket for now in the interest of focusing on the active issues but feel free to reopen this issue if you have more comments about it.
hi, how can insert class inside my anchor tags while working with wp-bootstrap-navwalker
http://stackoverflow.com/questions/42105407/how-to-make-custom-navigation-with-wordpress-wp-bootstrap-nawalker