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
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..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