Ajax URLs without #!, how to prevent falling into single.php on load or reload?

In short: do not use a single.php. If you only have a index.php, than all posts are displayed with this template because WP can not find any other template to display the content.

Your problem in a human language:

  • If the url is www.youpiemonday.com, load the frontpage (index.php, home.php or what else)

  • If the url is www.youpiemonday.com with a parameter, than display the single post within the parameter with single.php.

That’s what WordPress will do because youpiemonday.com/singlepost/ will be transformed (internaly) by WP into www.youpiemonday.com/?p=123 (where 123 is the post ID of singlepost)

So what you will do is this:

Everytime someone called www.youpiemonday.com, render the frontpage (index.php, home.php, …) with no single post in the portfolio opened. But if there is a paramter in the url (/singlepost/ ), than render the frontpage and open that single post (if available).

Delete or rename your single.php to force WP to use the index.php of your theme to display every kind of posts. To trigger the click, you can add a switch in your functions.php

add_action( 'wp_head', 'trigger_click_on_single_post' );

function trigger_click_on_single_post(){

$js_template="

<script type="text/javascript">

jQuery( document ).ready(

  function( $ ){

  // create the js to trigger the link here
     LinktoRef = $(".ProjectWrap" ).find( "a" ).href; // the href in the thumbnail

     if ( "{{link_to_click}}" === LinktoRef ){
       find( "a" ).trigger( "click" );
     }

   }

);

</script>

";


  if( is_single() ){

    global $post;

    $replace = get_permalink(); // create the propper url here

    $js_output = str_replace( '{{link_to_click}}', $replace, $js_template );

    echo $js_output;

  }
}

PS: I don’t not why, but the code formatting on WPSE don’t like the heredoc syntax. So there is a litte break in the codeblock.