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; ?>
4 Responses
Nice hack, but only usable on blog which publish a lot of articles per day.
add any screenshot brother
byme
@byme: I don’t add screenshots, unless necessary. I don’t have much time and I must keep the standard “one day/one recipe”
Trackbacks: