Working with WordPress and Bootstrap, you might be frustrated with the built in menu options. There isn’t an easy way to tell WordPress to swap out the current-menu-item class with bootstrap’s active class. Fortunately for you and me, there’s jQuery for that. Just a little dab will do ya.
jQuery(document).ready(function () { $(".current-menu-item").addClass("active"); });
This little blessed bit of jQuery will add the active class to your menu on the fly.
3 replies on “Adding the Bootstrap “active” class to a WordPress Menu Item”
You’re a hero man, thank you!
Still working (6/July/2016)
Works like a charm,
Insert it in the header.php enclosed in , right after the tag
jQuery(document).ready(function () {
$(“.current-menu-item”).addClass(“active”);
});