Link to home
Start Free TrialLog in
Avatar of Scott Walker
Scott WalkerFlag for United States of America

asked on

How to load a different menu based on current page in wordpress?

I have inherited a site from a new client who has a wordpress site that was heavily hand-coded by their previous webdev. The current code (in the header.php file) is:

//When page loads...
    $(".tab").hide(); //Hide all content
//Find URL location
var idToShow = location.pathname.split("/")[1];
//If URL location is one of these, then show its proper menu. If it isn't just show the home's menu.
if (idToShow == "unknown" || idToShow == "home" || idToShow == "parish" || idToShow == "formation" || idToShow == "school" || idToShow == "youth-ministry" || idToShow == "councils" || idToShow == "committees" || idToShow == "organizationsactivites" || idToShow == "contact") {
    $("#nav li."+idToShow).addClass("current").show(); //Activate first tab
    $("#"+idToShow).show();
}
else {
    $("#nav li.home").addClass("current").show(); //Activate first tab
    $("#home").show();
}

Open in new window


I am in the process of moving this site to a new host, and this works on the old host, but not the new host. I'm not sure where I could look for error logs (if there are any) or any other information that would help me solve this. Any ideas? Thanks!
Avatar of James Rodgers
James Rodgers
Flag of Canada image

this doesn't load a new menu,  all the menus are loaded  this hides   them all then shows one based on a  page name in the path.

unless you missed a file when migrating the code or the permalinks are not set properly, most likely, this should work

http://codex.wordpress.org/Using_Permalinks

see if that helps
ASKER CERTIFIED SOLUTION
Avatar of Morgan Finley
Morgan Finley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial