Using WP_Query To Get Posts Randomly From today

I don’t think there is a parameter value Today as you used in date_query.

If you want to return today’s post then you should provide date value to date_query as you stored current date in $today array. So here is your query now.

      $today = getdate();
      $args = array(
        'tag_slug__in' => array( 'destacado'),
        'posts_per_page' => 2,
        'post_type' => 'any',
        'offset' => 3,
        'orderby' => 'rand',
        'date_query' => array(
            array(
              'year'  => $today['year'],
              'month' => $today['mon'],
              'day'   => $today['mday'],
            ),
          ),
        'post_status' => 'publish',
        );

        $featured = new WP_Query($args);

Leave a Comment