I'm working on a WP single page portfolio that loads post content with AJAX. I read that WP doesn't need #! URLs to make it crawlable by Googlebot. If I understand it correctly, since Googlebot won't interpret ajax, it will just follow the link and index the article page, Am I right?
So I removed #! from my URLs and when a post is opened I update them with .pushState.
It's working fine, but if I hit F5 or if I try to load a specific URL (not the home) I fall into the page of the post (single.php).
To prevent it, I added a javascript redirection in single.php that leads users to the homepage. Then I need to open the content of the article on the home page.
Here is the address of my site: http://www.youpiemonday.com/ (the redirection isn't online yet).
How can I tell the browser "if you're coming from this article page, click on the corresponding thumbnail" (the click will load the content)?
I'm digging around this but I have no idea how to make it work...
<?php
$referer = $_SERVER['HTTP_REFERER'];
// search for the link correponding to the referer's URL and trigger a click on the href
if ($referer == 'SomeUrl') {
$('TheCorrespondingTumbnail href').trigger('click');
}
?>
I'm not really a programmer so any help would be very appreciated. And if you can comment your code, that would be invaluable to me.
Here is what the html looks like for each thumbnail:
<div class="ProjectWrap">
<a href="<?php the_permalink(); ?>" class="mosaic-overlay"><?php the_post_thumbnail(); ?></a>
<a href="<?php the_permalink(); ?>" class="mosaic-backdrop">
<div class="contentProject">
<h4 class="ProjectTitle"><?php the_title(); ?></h4>
</div>
</a>
</div>
Update: I try to write a more effective code here.
<script type="text/javascript">
$referer = document.referrer; // where we come from
$RefHref = $('.ProjectWrap').find("a").attr("href"); // the href in the thumbnail
if ($referer == $RefHref){
$('.ProjectWrap a').trigger('click');
}
</script>
