Hi,
I'm just trying a new WP3 custom menu function and I don't see a way how to display a homepage link. We can of course display it by "Custom Links" feature but it doesn't highlight (add a class) while its active.
As far as I know there is no way how ti hide the first ul tag (so we could wrap it by own ul and hardcode a homepage link into it).
Did you figured something out please?
Thanks, Jakub
If you're using a static front page, you should find that the page will have the current_page_item attached to the <li> in a custom menu.
Hi,
unfortunately it's a dynamic (index.php) page.
blackmesa
Member
Posted 2 years ago #
Does anyone have an answer to this, it's supremely frustrating.
phrozenRa
Member
Posted 2 years ago #
My workaround to this problem:
I set a custom link pointing to "index.php" without http://
then I'm using a bit of jQuery to add the right class to the right menu item when the visitor is on the home page:
<?php if ( is_home() || is_front_page() ): ?>
<script>$('#menu-id li:first').addClass('current-menu-item');</script>
<?php endif; ?>
ghost1227
Member
Posted 2 years ago #
Trying to follow phrozenRa's suggestion, I added the following, but it doesn't seem to work. Any suggestions?
<?php if ( is_home() || is_front_page() ): ?>
<script>$('div#menu1 ul.rMenu li:first').addClass('current-menu-item');</script>
<?php endif; ?>
ghost1227
Member
Posted 2 years ago #
Correction... I got it working. Then I modified it. I'm now using the following, which works. However, for some reason, single posts don't work still.
<?php if ( !is_page(array('page1','page2')) ): ?>
<script>$('div#menu1 ul.rMenu li:first').addClass('current-menu-item');</script>
<?php endif; ?>