I want to create a page labeled "Today's News" which displays a simple bulleted list of all posts published on the current day and grab the current date based on the server's date/time. Is this feasible?

Thank you for any help.

2 Answers 2


Use query_posts

$day = date('j');
query_posts( "day=$day&order=ASC" );

Is this feasible?


get_posts(); is your best friend. No need to modify the query or run a new one.

// Call it with the date you need as input argument
function wpse28632_get_daily_posts( $date = null )
    $posts = get_posts( array( 'order_by' => 'post_date' ) ); // additional arguments - see Codex
    echo '<ul>';
    foreach ( $posts as $post )
        if ( $date == $post->post_date )
            echo "<li>{$post}</li>";
    echo '</ul>';
  • 1
    What is there are thousands of posts - should you get all of them just to list today's ones? Sep 15, 2011 at 18:07
  • If there are about hundreds of thousand, both visitors & posts, then you could try to do a direct SQL query for a better performance. Else the index just works fine. Also: get_posts(); is nothing else than a new WP_Query. This has two advantages: 1) It's easier than doing a new query, saving the object and picking the stuff you need and the args are partly shared with query, but just simplified. Imo array is easier to understand for most than object. 2) Less chance to make failures. If you don't save the result in some var, it will be performed, but nothing happens.
    – kaiser
    Sep 15, 2011 at 23:43
  • 1
    @Darhazer. Btw: Read here for better insights. Andrej fetched it up pretty well.
    – kaiser
    Sep 16, 2011 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.