HippySunshine
Senior Member
On a WordPress site, I have a quote generator which needs to be displayed on every page (as a screen overlay) when that page is loaded from and external URL only.
So when the site/page is visited from google, the quote will load on that page. When navigation internally through the site, none of the pages will load the quote.
This is pretty hard to explain so I hope it makes sense.
I currently have the following code, but the quote loads on every page load, even when navigating internally through the site, and I don't want that.
This is a tad new to me, never done it before, so if someone could point out where I've gone wrong, if you at all understand my terrible explanation, that would be great.
This is also pretty hard to test on a local WP site :/
HTML: Firstly, is the header.php the best place for this?
This is in my custom.js:
Thank you![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
So when the site/page is visited from google, the quote will load on that page. When navigation internally through the site, none of the pages will load the quote.
This is pretty hard to explain so I hope it makes sense.
I currently have the following code, but the quote loads on every page load, even when navigating internally through the site, and I don't want that.
This is a tad new to me, never done it before, so if someone could point out where I've gone wrong, if you at all understand my terrible explanation, that would be great.
This is also pretty hard to test on a local WP site :/
HTML: Firstly, is the header.php the best place for this?
HTML:
<div class="quote-overlay">
// the quote plugin shortcade to randomly load the quotes
<?php echo do_shortcode('[quotcoll orderby="random" limit=1]'); ?>
</div>
This is in my custom.js:
JavaScript:
$(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');
}
})
Thank you