最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - WP_Query() displaying past postevent

programmeradmin5浏览0评论

I'm making a page for past events (using Event Expresso plugin) and I'm kinda confused about the wp_query.

This one works:

$atts = array(
      'title' => NULL,
      'limit' => 100,
      'css_class' => NULL,
      'show_expired' => true,
      'month' => NULL,
      'category_slug' => NULL,
      'order_by' => 'event_start_date',
      'sort' => 'DESC',
      'date_query' => array(
          array(
              'column' => 'event_start_date',
              'before' => '1 month ago',
          ),
      ),
    );

However, this one won't work (it will still show event past May 11):

$atts = array(
      'title' => NULL,
      'limit' => 100,
      'css_class' => NULL,
      'show_expired' => true,
      'month' => NULL,
      'category_slug' => NULL,
      'order_by' => 'event_start_date',
      'sort' => 'DESC',
      'date_query' => array(
          array(
              'column' => 'event_start_date',
              'before' => '2020-05-11 23:59:59',
          ),
      ),
    );

Is there something wrong with my code?

The column 'event_start_date' returns the event date when I do print_r($post->event_start_date); inside a post loop.

I'm really confused why the 2nd code does not work.

I also tried

'before' => 'now',

and

'before' => 'today',

and its not working. :(

发布评论

评论列表(0)

  1. 暂无评论