-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Active Class Font Color Not Working #528
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi @ferryfernando, there's a change from Bootstrap 4 to Bootstrap 5 regarding the placement of the Put this in your add_filter( 'nav_menu_link_attributes', 'prefix_add_active_class_to_anchor', 10, 3 );
function prefix_add_active_class_to_anchor( $atts, $item, $args ) {
if ( false === prefix_is_active_wp_bootstrap_navwalker_item( $item, $args ) ) {
return $atts;
}
if ( isset( $atts['class'] ) ) {
$atts['class'] .= ' active';
} else {
$atts['class'] = 'active';
}
return $atts;
}
function prefix_is_active_wp_bootstrap_navwalker_item( $item, $args ) {
if ( ! property_exists( $args, 'walker' ) || ! is_a( $args->walker, 'WP_Bootstrap_Navwalker') ) {
return false;
}
if ( ! $item->current && ! $item->current_item_ancestor ) {
return false;
}
return true;
} If you also want to remove the add_filter( 'nav_menu_css_class', 'prefix_remove_active_class_from_li', 10, 3 );
function prefix_remove_active_class_from_li( $classes, $item, $args ) {
if ( false === prefix_is_active_wp_bootstrap_navwalker_item( $item, $args ) ) {
return $classes;
}
return array_diff( $classes, array( 'active' ) ) ;
} Let me know if that helps. |
It's working! Thank you <3 With up to date Wordpress and Bootsrap |
inside class-wp-bootstrap-navwalker.php file add style or class
|
Steps to reproduce the issue:
I use:
What I expected:
Active page link have white color.
What happened instead:
Active page link color not change.
The text was updated successfully, but these errors were encountered: