0

I have noticed this becoming a trend with comments and now posts. I’m sure many sites (especially community ones) will implement this.

Here’s exactly what I mean, click here: https://stackexchange.com/questions?tab=realtime

Posts appear in real time as soon as they are published.

There are also another version of this where the expand link appears with (1 question with the new activity). You can see this in action here if you wait for several seconds: https://superuser.com/

I’m wondering is there any way to do this on WordPress? With my loop?

Right now my loop looks like this:

<?php 
// Limit query posts to the current day
// 
$period = $_GET["period"];
$day = $_GET["d"];
$year = $_GET["y"]; 
$args = array(
    'year' => (int) date($year),    
    'monthnum' => (int) date( 'M' ),    
    'day' => (int) date($day), 
    'date_query' => array(
        array(
            'after' => ($period), 
        )
    )
    
);

$query = new WP_Query( $args );

// The Loop
while ( $query->have_posts() ) :
    $query->the_post();
        
get_template_part( 'template-parts/content', get_post_type() );
            
endwhile;
the_posts_navigation();

?>

I think this would help a lot of people. Thanks.