WordPress.org

Ready to get started?Download WordPress

Forums

Homepage link in WP3 custom menu (7 posts)

  1. Machi
    Member
    Posted 3 years ago #

    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

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    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.

  3. Machi
    Member
    Posted 3 years ago #

    Hi,
    unfortunately it's a dynamic (index.php) page.

  4. blackmesa
    Member
    Posted 3 years ago #

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

  5. phrozenRa
    Member
    Posted 3 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; ?>
  6. ghost1227
    Member
    Posted 3 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; ?>
  7. ghost1227
    Member
    Posted 3 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; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic