I want to know how to get previous 10 days post from a specific date, as I know that it can be done from current date as below
$args = array(
'post_type' => 'post',
'date_query' => array(
'after' => '- 10 days'
)
);
$query = new WP_Query( $args );
But I want posts previous 10 days post from a specific date. Is it possible ?
Yes, it is possible. You can pass full date as before and after params, so:
$given_date_as_time = strtotime('2017-11-22 00:00:00');
$args = array(
'post_type' => 'post',
'date_query' => array(
'before' => date( 'c', $given_date_as_time ),
'after' => date('c', strtotime( '- 10 days', $given_date_as_time ) ),
),
);
$query = new WP_Query( $args );
above query is also correct and will give you result you wanted.