Conditions for refering entity
-
Hi,
I’m trying to implement conditions for the following.
- if referer is external URL return false
- if referer is home / front page return false
- if referer is page from website, return the post ID URL in anchor and display title
I’ve got everything working beautifully except if the referer is the home page etc.
The main issue is with a home page slider and if you click on a slide the condition thinks it’s true and fires off the code and I don’t want it to do that.
Here’s my code:
$refering_page = get_the_title( url_to_postid(wp_get_referer()) ); $home_refer = !is_home(); $referer = wp_get_referer(); if ($referer == $home_refer){ if(!empty($_SERVER['HTTP_REFERER'])) { if(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) == $_SERVER['HTTP_HOST']) { echo '<a href="Javascript:window.history.back();">« Back to '.$refering_page.'</a>'; } } } else {echo 'nope';}
Any insight is appreciated.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Conditions for refering entity’ is closed to new replies.