Determining the current time
current_time() function in core that allows to pass three different values as first argument and
gmt (the offset) as second argument. About the 1st:
gmdate( 'Y-m-d H:i:s' ), human readable e.g
time(), the UNIX timestamp for e.g.
A custom argument that is a valid formatting string for PHPs
D, d M Y H:i:s
Now we will just go with
$now = current_time( 'mysql' );
to not get the UNIX timestamp of (pretty much) now, as the
WP_Query will need something that she can transform to a UNIX timestamp using
Querying for newer posts
Then we will use the
date_query clause with
after to query posts later than now. I use the
fields argument there to reduce the impact on the database. That means that the result will just be used to check if we got newer posts and only fetch the IDs instead of whole rows.
$newer_posts_IDs = new WP_Query( array(
'post_type' => 'post',
'fields' => 'ids',
'date_query' => array(
'after' => current_time( 'mysql' ),
$newer_posts_IDs->found_posts will hold the amount of posts for the query.
Where to go from here?
What you consider to be "finished" is up to you. You could add above query/check to something like the jQuery
( document ).ready() event, add it to the
shutdown hook or whatever pleases you.
Finally you will need to repeat above query with a whole set of rows, fetched via ajax. Search through my answers on that topic.
You probably want to insert them on a specific point in DOM and add an empty container there as placeholder. jQuery offers the
.before() API function in case you already got posts. Else you will probably just use
.html() to insert your content.