In order to query posts with a date_query
, you can pass the argument of column post_date_gmt
which is the date the post was published, and then pass the argument of before/after
and a string to represent your request. So for published posts from now until 90 days ago, you would put this in your WP_Query
args:
'date_query' => array(
array(
'column' => 'post_date_gmt',
'after' => '90 days ago',
)
)
This says get me all posts from 90 days ago and AFTER, which would stop at present time.
You could pass the string 3 months ago
, 1 year ago
, etc. It basically takes on the same behavior of strtotime()
.