Is there a way of doing this with WordPress aside from using $_SERVER['HTTP_REFERER']?

Maybe something like a blend of $_SERVER['HTTP_REFERER'] and is_category(). Something like,

came_from_category( 'uncategorized' )


  • So you want to process the HTTP_REFERER to work out what page it was and test properties of it?
    – Rup
    Mar 27, 2019 at 10:12
  • 1
    Or are you looking for an alternative mechanism? There isn't AFAIK any built-in user session where you could store their navigation path but you could add one.
    – Rup
    Mar 27, 2019 at 10:12
  • I'm planning to have several pages that will display different color depends on where is the user coming from. Say, if the user comes from home, it would display the color blue (via attaching the blueclass). If they come from other specific category, it would display the color green.
    – deathlock
    Mar 27, 2019 at 10:14
  • The simplest way may be to have those different pages generate a query string param on your page to indicate which color to use, and the you check for that query string in a plugin and write it to a cookie to remember for future pages.
    – Rup
    Mar 27, 2019 at 10:36


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.