0

I would like to create WP_Query query and I am using date parameters. How should I should write my query if I want to get all posts from: January 2019 and May 2019 (there is not range).

2

It's possible to pass multiple sets of arguments to date_query, so if you set relation to OR for them, you should get posts that match either, meaning that you could get the posts you want like this:

'date_query' => [
    'relation' => 'OR',
    [
        'month' => 1,
        'year'  => 2019,
    ],
    [
        'month' => 5,
        'year'  => 2019,
    ],
],

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.