Support » Themes and Templates » Homepage link in WP3 custom menu

  • 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

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    (@esmi)

    Forum Moderator

    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.

    Does anyone have an answer to this, it’s supremely frustrating.

    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; ?>

    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; ?>

    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; ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Homepage link in WP3 custom menu’ is closed to new replies.