Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a site with three menus, one per main category of the site. I use pages only. Two main categories have one page in common.

  • Category A with menu a
  • Category B - with menu b - with tarifs page
  • Category C - with menu c - with tarifs page

That tarifs page has to be shown with the proper menu depending on what menu the tarif page was asked from. I tried giving the page the template for main category A realizing I couldn't do that as it would show the wrong menu when it would be picked from the other main category with the same page - category B.

Is there a way to show menu a or b for the tarifs page depending on the menu the user came from? I would be very happy if I could create a tarifs template that could do this.

Update:

$_SERVER['HTTP_REFERER'] could be used to determine page / url of origin using HTTP_REFERRER. I found http://stackoverflow.com/questions/4909443/using-php-serverhttp-referer-to-display-custom-welcome-messages-content mentioning using strpos and HTTP_REFERRER to check for url of origin.

Only wish there would be a nicer way to check for template chosen (body class) and then echo code x

share|improve this question
    
I made the tarifs page a post under several categories. I thought I could use the category as a way to determine what menu to show. If in_category('pros)) { echo "menu-1";}. But the issue is that the if elseif, else statement I used is always true and I therefore I will get the menu stated in the if statement and never in the elseif or else statement. This so because the post is under all three categories in statement. How do I filter? Looking into cat ID now, but I need something like if pros is in url or permalink.. –  rhand Feb 24 '12 at 10:27
    
Found code to grab current url here: webcheatsheet.com/php/get_current_page_url.php. Actually not to hard. Just need to get a check for cat slug now and then an if elseif. Checking PHP string functions now. –  rhand Feb 24 '12 at 11:05
    
Solved it here with the help of stack exchange folks: stackoverflow.com/questions/9430539/… –  rhand Feb 24 '12 at 12:50
    
Hmm, as I have several pages with content + child pages underneath I cannot convert those into posts as I need some to be posts and categories to make my hack work. And then I wind up having pages domain.com/regular-clients/tarifs/tarifs . I do not want to repeat a term in an url, but I do not want to create the tarifs page two times either. Too bad WordPress does not support the adding of one child under more than one parent. Been Googling on this for quite a while now, but have not found a good hack for this issue –  rhand Feb 26 '12 at 2:51
add comment

1 Answer

up vote 0 down vote accepted

Going to use a site setup where each page has only one specific parent and where there is only one main menu and a sidebar that loads page children. Easier and clearer that way.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.