How to use WP_Query to filter posts modified after a specific date

It is possible, using the date_query argument. By default this uses the publication date, but you can tell it to use the modified date by using the column argument. So if you wanted to query all posts modified after June 30th 2019, you’d use:

'date_query' => [
    'column' => 'post_modified',
    'after'  => [
        'year'  => 2019,
        'month' => 6,
        'day'   => 30,
    ],
],

The column parameter of WP_Date_Query supports:

  • post_date (default)
  • post_date_gmt
  • post_modified
  • post_modified_gmt
  • comment_date
  • comment_date_gmt

A WP shell example for the date query in WP_Query with post_modified_gmt and the after parameter:

wp> echo ( new WP_Query( [ 'date_query' => [ [ 'column' => 'post_modified_gmt', 
  'after' => '2 days ago' ] ] ] ) )->request;

will output:

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM tfl_posts  WHERE 1=1  AND (
  wp_posts.post_modified_gmt > '2019-11-16 10:00:27'

For further information look e.g. into the dev documents here:

https://developer.wordpress.org/reference/classes/wp_date_query/
https://developer.wordpress.org/reference/classes/wp_query/#date-parameters

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)