kalpesh.mistry
Member
Posted 8 months ago #
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...
kalpesh.mistry
Member
Posted 8 months ago #
kalpesh.mistry
Member
Posted 8 months ago #
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; ?>
kalpesh.mistry
Member
Posted 8 months ago #
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.