• sam

    (@samjoelnang)


    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 sam.
    • This topic was modified 3 years, 10 months ago by sam.
    • This topic was modified 3 years, 10 months ago by sam.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • In order to maintain the query variable, you would need to change a lot of things.
    Wouldn’t it be easier if selecting a region set a cookie, and the plugin that sets the cookie would then be the one to check for the cookie and modify the page through filters and actions (CSS and content)?
    Can other visitors see the custom page without clicking the region? If it is a separate page (which only handles the “home” scenario), it’s a separate address that could be entered into the address bar, even if it’s not linked anywhere.

    This scheme seems a bit elaborate for filtering a subcategory. It might even be confusing for the user that the menus behave differently sometimes.

    Thread Starter sam

    (@samjoelnang)

    Hi Joy, thanks for your response. I would like to know more about what you’re trying to recommend using a cookie. How do you think I can implement that?

    Basically this is what I’ve created:
    https://www.website.com (the main site; all articles appear except for some articles that have a specific taxonomy that is only viewable in the custom front page)
    https://www.website.com/ph (the custom front-page copy; only those articles with the above taxonomy + several others that also appear on the main front page appear here)

    I did this with the understanding that when the user arrives at that custom front page, it should mean that they’ve opted to view the local version of the site, thus, the homepage should also always redirect them to /ph even after they visited a /page-name (which of course belongs to the same original site) until they click on the default / again, which shall remove the rule.

    So when I go to https://www.website.com and click (or when i go directly to) https://www.website.com/ph, the homepage now will be https://www.website.com/ph, regardless where i go. when i click the default region, the homepage reverts to the original site.

    First, by making a separate page, the address changes. That is fine, but confusing to users since it is duplicating content, which is also bad for SEO. The page will be in the sitemap by default. If there are two pages, the user should be able to see both, or why bother making two pages?

    Perhaps if you think of (and label it) your region link as a taxonomy toggle, so the user can hide or show that taxonomy, then the plugin could use a cookie to affect whether that taxonomy is part of the query or not, with no extra pages.

    Thread Starter sam

    (@samjoelnang)

    Appreciate your inputs, Joy. That seems to be a good idea indeed. Do you know how that “taxonomy toggle” can be created and made operational?

    I only intended the /ph page to act as a starting/landing page to users who want their session with localized content or those directly referred to it. It’s not actually intended to rank. And correct, the user is able to see both homepages, but should not be during the same session (they need to switch from either).

    With your suggestion, though, I am thinking you mean there’s no longer a need for the /ph custom front page and just the toggle to make visible specific content based on taxonomy. Correct? In that case, can the user browse the site while persistently being fed the same content until the toggle is switched again? If so, I’m interested in trying that out. Btw, is there a way I can also customize some sidebar widgets to only show while the toggle is activated? Sorry for asking so many questions.

    • This reply was modified 3 years, 10 months ago by sam.
    • This reply was modified 3 years, 10 months ago by sam.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Force redirect to preferred website homepage version by adding parameter to URL’ is closed to new replies.