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; ?>
6 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”
This will actually give me all posts with the same day number…
If today’s Oct 13. Sept 13. posts are also returned.
Works this code with wordpress 2.9.1?
Thanks for next useful recipe
Dekoracje Tort
Trackbacks: