I'm trying to make things properly with a single page ajax powered portfolio. I've read that there is no need of #!
to make it crawlable by google. So I have clean URLs that updates with .pushState
when I load a post.
My problem is that if you hit F5 or load directly an URL, you fall into the single.php.
You can try it yourself here: http://www.youpiemonday.com/
How can I prevent falling into the article page?
I thought about redirecting from the single.php to the home and trigger the opening of the post there. But seing the comments, it doesn't seems to be a great idea. Anyway I'm stuck right now... You can see my thought process on StackOverflow here.
I'd love to here some feedback from Wordpress specialists... :)
EDIT: I may have found a simple/quick way to redirect to the homepage if the request is done when on single.php. I simply added this to function.php
add_action('wp', 'RedirecToPost');
function RedirecToPost(){
if($_SERVER['HTTP_X_REQUESTED_WITH']=='' && is_single()){ // if http request AND on single.php
wp_redirect( home_url() ); // redirect to home
// THEN check the post requested AND trigger a click on its thumbnail
}
}
But I'm still at the same point. I need a way to check what was the requested post and trigger a click on its thumbnail. Now I'm really stuck by my scripting knowledge. How can I check the last page url (referer?) and find the href pointing to it in the current page?