0

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 https://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

4
  • 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, 2012 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, 2012 at 11:05
  • Solved it here with the help of stack exchange folks: stackoverflow.com/questions/9430539/…
    – rhand
    Feb 24, 2012 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, 2012 at 2:51

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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