If for some reason, you want to display only today’s posts on your blog homepage – or any other page – here’s a simple way to get theses posts and display it on your WordPress blog.
If for some reason, you want to display only today’s posts on your blog homepage – or any other page – here’s a simple way to get theses posts and display it on your WordPress blog.
If you provide a lot of posts per days, it can be nice to display only today's posts on a separate page. To achieve this, we'll use the php date() function, and the WordPress query_posts() function.
Paste the following code where you want today's posts to be displayed:
$current_day = date('j');
query_posts('day='.$current_day);
if (have_posts()) :
while (have_posts()) : the_post(); ?>
// WordPress loop
endwhile;
endif; ?>
Leave a Comment