简体   繁体   中英

Load specific content only when site is visited from external source

I am building a WordPress site for a client and they want a random quote to display on every page on page load but only when the page is visited from an external source. They don't want it to show when the user is navigating through the site.

How on earth do I achieve this?

UPDATE

I have this solution in my .js now, which works to a certain point. It's loading on every internal page click. I only want it to load on a page when it's visited from an external source, say google.

 $(document).ready(function () { var referrer = psl.parse(document.referrer.toString().replace(/(^\\w+:|^)\\/\\//, "").replace(/\\/$/, "")); var current = psl.parse(document.location.toString().replace(/(^\\w+:|^)\\/\\//, "").replace(/\\/$/, "")); if (referrer.domain !== current.domain) { $('.quote-overlay').show().delay(2500).fadeOut('slow'); } })

This is my basic html which is in my header.php file:

 <div class="quote-overlay"> <p>Text content here</p> </div>

$_SERVER["HTTP_REFERER"]是您要查找的内容,如果满足某些要求,您可以使用条件语句来显示您的内容

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM