admin管理员组

文章数量:1122832

I have a page template, which redirects to the homepage using this:

wp_redirect( home_url() );

Now, on the homepage is it possible to check if it has been redirected from a specific page template without knowing the URL of that page?

I have a page template, which redirects to the homepage using this:

wp_redirect( home_url() );

Now, on the homepage is it possible to check if it has been redirected from a specific page template without knowing the URL of that page?

Share Improve this question asked Dec 16, 2014 at 10:05 jayjay 11 bronze badge 1
  • possible duplicate of Get default permalink structure from pretty URL's – Pieter Goosen Commented Dec 16, 2014 at 11:47
Add a comment  | 

1 Answer 1

Reset to default 0

You can use the $_SERVER['HTTP_REFERER'] to check the page where it redirected from

You can use it as below.

if($_SERVER['HTTP_REFERER'] == "path-of-page-you-want-to-check"){
//Do something here
}

Conditionally you can call functions like is_home(), is_front_page() to run that block of code in homepage only

本文标签: theme developmentCheck if redirected from a specific page template