Add class to menu item.
Posted: Tue Jan 29, 2019 7:23 pm
I want add class="active" to current static page.
Installation - Bugs - Plugins - Hacks - Tips & Tricks
I'm also looking for a solution. I downloaded the theme, but it doesn't work, class='current' does not apply to the current pageEdi wrote: ↑Tue Jan 29, 2019 7:54 pm The theme Keep It Simple gives you an example:
https://github.com/bludit-themes/keep-i ... ar.php#L29
Code: Select all
<!-- Static pages --> <?php $current_page = $_SERVER['REQUEST_URI']; foreach ($staticContent as $staticPage) : ?> <li <?php if ($current_page == '/' . $staticPage->slug()) echo 'class="current-menu-item"'; ?>> <a href="<?php echo $staticPage->permalink(); ?>"><?php echo $staticPage->title(); ?></a> </li> <?php endforeach ?>