Add class to menu item.
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
The theme Keep It Simple gives you an example:
https://github.com/bludit-themes/keep-i ... ar.php#L29
https://github.com/bludit-themes/keep-i ... ar.php#L29
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
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
http://bludit.eu5.net/
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 ?>
funny, it works correctly on hosting, but it doesn't work on the local server