How to display the modified post today

I’m trying to figure it out how to display a post with modified/updated today. Sql is possible with post_modified_gmt < ‘datetoday’ but can’t find the function for post_modified_gmt on wp_query. Any idea? Thank you.

$args = array (
    'post_type'              => array( 'post' ),
    'post_status'            => array( 'publish' ),
    'category_name'          => 'Airing'

);
$query = new WP_Query( $args );

1 Answer
1

You can use the date_query part of WP_Query. Here’s an example:

$args = array (
    'post_type'          => array( 'post' ),
    'post_status'        => array( 'publish' ),
    'category_name'      => 'airing',        //<-- N.B. This is for a category slug!
    'date_query'         => array(
        array(
            'column'     => 'post_modified_gmt',
            'after'      => 'today',
            'inclusive'  => true
        ),
    )
);
$query = new WP_Query( $args );

This should give you wp_posts.post_modified_gmt >= '2015-09-24 00:00:00' in the generated SQL query, if today is Sep 24. 2015.

Leave a Comment