X

Display today’s posts only

Adding this PHP code to your wordpress theme will display your wordpress post but only from the current day.



Code Snippet:


<?php
$day = date('j');
query_posts('day='.$day);
if (have_posts()) :
while (have_posts()) : the_post();
?>

<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="view: <?php the_title(); ?>"><?php the_title(); ?></a></h3>
<div class="storycontent"><?php the_content(); ?></div>

<?php endwhile; ?>
<?php endif; ?>

Comments  Leave a Reply

  1. Thanx Man…..

  2. Ferhat Korkut July 11, 2013 at 5:54 am

    Thanks dude :))

  3. The above snippet shows all posts published at the same day of any month. (ex shows posts for sept 24, oct 24, nov 24 etc.)

  4. Thanks for this. Found it to be a great snippet. Could you extend this code to only display todays content from specific category?

  5. Tweets that mention Wordpress Display today’s posts only – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com January 28, 2011 at 3:07 pm

    […] This post was mentioned on Twitter by Michael Davis, WPSNIPP. WPSNIPP said: #wordpress Display today’s posts only http://bit.ly/fOIjxy #blog please RT 🙂 […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!