How to generate a list of posts published on current day?

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.

Related posts

Leave a Reply

3 comments

  1. Is this feasible?

    Yes.


    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>';
    }
    
  2. Is it feasible to create a page like this, where I can see a list of all posts on the current day, and grab the current date based on server time?