• Well I’m not a developer, yet I try to explore such stuff to improve my blog. I’ve been trying to display some recent posts published in last 60 minutes.

    <?php
    		$my_query = new WP_Query('showposts=3&minute=60');
    		while ($my_query->have_posts()) : $my_query->the_post();
    		$do_not_duplicate = $post->ID; ?>
    
    			///Contents
    
    	<?php endwhile; ?>

    I took some help from here, http://codex.wordpress.org/Class_Reference/WP_Query … but minute=60 doesn’t work for me.

    Need help here…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kalpesh.mistry

    (@kalpeshmistry)

    Anyone?

    Thread Starter kalpesh.mistry

    (@kalpeshmistry)

    Okay well, the issue’s resolved now. Thanks to this – http://wordpress.org/support/topic/get-posts-from-the-last-60-minutes-from-a-given-category#post-1333759

    I’ve re-edited the codes.

    <?php
    
    		function filter_where( $where = '' ) {
    		$where .= " AND DATE_SUB(NOW(),INTERVAL 60 MINUTE) <= post_date";
    		return $where;
    		}
    
    		add_filter( 'posts_where', 'filter_where' );
    		$my_query = new WP_Query('showposts=3');
    		remove_filter( 'posts_where', 'filter_where' );
    		while ($my_query->have_posts()) : $my_query->the_post();
    		$do_not_duplicate = $post->ID; ?>
    
    			// Contents
    
    	<?php endwhile; ?>
    Thread Starter kalpesh.mistry

    (@kalpeshmistry)

    Ahh… new problem arises here. I can retrieve articles published within an hour, that is 60 minutes. But I cannot retrieve articles published within somewhat 5 minutes. Even if I change the interval to INTERVAL 5 MINUTE, it shows articles published within 60 minutes. Tried everything I could, but everything remains same.

    Guys, please, help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show recent posts of the last 60 minutes’ is closed to new replies.