• Hello.

    This morning I transferred a site from one server (development) to another server (production). I’m currently QA’ing and noticed an issue with the main nav: the “home” button is not highlighted on the homepage, but was on the previous server.

    I’m using a home.php file as the homepage (FYI: Settings > Reading > front page displays set to “your latest posts”). I’m also using the built-in menu tool for this main nav:

    <?php wp_nav_menu( array('menu' => 'Main Menu' )); ?>

    For the the home nav button within the “Menus” admin, I’m using a “Custom Links” button with the URL set to the new domain (http://newsite.com).

    Looking at the source code for the homepage, it looks like the list item is not being set to “current”. Right now, it appears as:

    <li id="menu-item-47" class="first menu-item menu-item-type-custom">

    Previously, I believe it appeared as:

    <li id="menu-item-47" class="first menu-item menu-item-type-custom current_page_item">

    Thus providing me the hook (current_page_item) to highlight it.

    Any help would be appreciated.
    Mike

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter redone75

    (@redone75)

    I’m using a band-aid fix while I try to figure out what’s causing this. If anyone’s interested, here’s what I did.

    Since I’m already using jquery on the homepage and throughout the site, I tapped into it to solve the issue visually by placing the following code after the main nav:

    <?php if (is_home()){
    	echo '<script>
    	     $("#menu-main-menu li:contains(\'Home\')").addClass("current_page_item");
        	  </script>';
    } ?>

    Had this same issue. First, the class only gets added if you have a trailing slash on your link (http://yourlink.com/). This only works for one domain at a time though.

    I wanted to get it working for dev, staging and live servers without having to update. My fix was to add a class in on that custom link (home-link) and add “.home .home-link” to the same css class that was applying my current-menu.item hover.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Home main nav not highlighted as current – using home.php’ is closed to new replies.