Displaying a different Menu from Referrer
-
I’ve been trying to implement a function where if a person clicks a link from a specific referrer like “yoursite.com” a different Nav Menu will appear on the page it’s directed to.
I’ve had a bit of success with:
$referer_parse = parse_url($_SERVER['HTTP_REFERER']); if(strpos($referer_parse['host'], 'yoursite.')!==false) { wp_nav_menu( array( 'menu' => 'Replacement Menu' ) ); }But the Primary Menu is still there and the Replacement Menu isn’t formatted properly.
A little background as to why I’m trying to do this:
The client sells items on their main domain (company1) via WooCommerce, but has another domain (company2) they wish to sell the same items. Seems to me you would have to set up a new WooCommerce store, which messes with item stock etc. My idea was to re-direct (company2) to (company1) but the client wants to avoid showing (company1) navigation if someone comes from (company2) – but maintain the (company1) navigation if they shop via (company1).In simpler terms…lol:
1. Someone visits (Company1) and goes to the WooCommerce Shop – Primary Menu is fine.
2. Someone visits (Company2) and it redirects to only the WooCommerce Shop at (Company1) but Primary Menu is not fine, should be a standalone Replacement Menu.
How do I tell WordPress to only show Replacement Menu if a visitor comes via (Company2)
The topic ‘Displaying a different Menu from Referrer’ is closed to new replies.