Force redirect to preferred website homepage version by adding parameter to URL
-
I wanted to create a local version of an existing website. I’ve already tried experimenting with multisite, CPTs, etc. but none worked for me. Today I decided it’s best to stay on the same website and just create/modify a certain page to use as the “other homepage”. I’ve already done this and I’ve even widgetized the page to replicate the “main homepage” but only show content that’s relevant to the user visiting/choosing to view that homepage.
What I’m trying to achieve is: I want the user to be able to choose their preferred region by clicking on it on the menu, for example (there are two: International [the main/default] and Philippines [showing localized content; basically mimics the frontpage]).
I want the site to work as is except when the user clicks on Philippines. When they do so, I want the following to happen:
- homepage URL to always return to the Philippines custom homepage
- when a navigation menu (including category/tag/taxonomy) is clicked, it will try to look for a version of it which has the custom homepage “slug” prepended to the URL; if none, proceed to the default content, but keep the same custom homepage URL set
- maintain the state even after refresh or opening to a new tab/window
- go back to normal only when the user clicks International again
This way there won’t be a need to duplicate posts (only alternate archives as needed or desired). Also we can keep publishing just normal posts. The gist is that, the contents are simply filtered on the “alternate” homepage/pages/archives of the site while preserving the logical state expected by the user choosing their preferred homepage/content.
I was thinking maybe this is achievable by adding a certain parameter to the URL once “Philippines” is clicked/chosen and retain that parameter throughout the session until the user reverts to the default site. Like, the URL becomes https://www.website.com/ph?region=ph; or https://www.website.com/about?region=ph; or if page version exists, https://www.website.com/ph/news?region=ph; while it goes back to just https://www.website.com; https://www.website.com/about; https://www.website.com/news when “International” is clicked again. When a user enters a /ph specific page like https://www.website.com/ph/news while in session on the default, redirect them to the default version until they actually set their session to Philippines (therefor adding the parameter).
I was thinking the parameter, when preserved while the user browses the site, can tell WordPress to make the homepage redirect to the “/ph” version (if not make the homepage irrevocably “/ph”) until it’s deliberately removed from the URL or the user returns to the default International version.
It would also be awesome if the words International and Philippines become red whenever they’re “considered” active.
The “other homepage” I’m talking about is not yet live, as well as the “Select region links”, but I hope my explanation is clear enough to help you visualize it. I would appreciate it if you have other ideas on how this can be done, although for now this is what I’ve been considering. Thanks! Sam
- This topic was modified 3 years, 10 months ago by .
- This topic was modified 3 years, 10 months ago by .
- This topic was modified 3 years, 10 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘Force redirect to preferred website homepage version by adding parameter to URL’ is closed to new replies.