How To Show Today’s Posts

If you need to show just today’s posts on your blog/site homepage or some other page – here’s a simple method to pick up those posts and show it on your WordPress site. If you publish a lot of posts each day, it can be pleasant to show just today’s posts on a separate page. To accomplish this, we’ll employ the PHP date() and WordPress query_posts() function. Paste the following code anywhere you’d like today’s posts to show up:
1
2
3
4
5
6
7
8
$current_day = date('j');
query_posts('day='.$current_day);
if (have_posts()) :
    while (have_posts()) :
        the_post();
        // WordPress loop
    endwhile;
endif;
$current_day = date('j');
query_posts('day='.$current_day);
if (have_posts()) :
	while (have_posts()) :
		the_post();
		// WordPress loop
	endwhile;
endif;