Individual months in WP Query

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 ge

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).

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).

Share Improve this question edited Nov 25, 2019 at 12:42 butlerblog 5,1213 gold badges28 silver badges44 bronze badges asked Nov 25, 2019 at 7:16 Damian TokarczykDamian Tokarczyk 1254 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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,
    ],
],

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744971673a4604003.html

相关推荐

  • Individual months in WP Query

    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 ge

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信