Exclude Timestamp in post query

Question

On this site, https://cregy.uk/ all posts are filtered by day, so only posts dated for today’s date will show excluding the year. However, the filter doesn’t take account of time so if I posted at 15.45 on that day it won’t show the post until that time is reached. I need the filter to show all posts and exclude the time function. Here is the code I currently have:

add_action('pre_get_posts', 'cgy_same_day');
function cgy_same_day( $query ) {
  if ( $query->is_home() && $query->is_main_query()) {
    $query->set('date_query', array(
    array(
      'day' => date( 'j' ),
      'month' => date( 'n' ),
    ),
    ));
  }
  return;
}

I am trying to understand the use of the function strtotime but am finding it difficult to work out how to exclude this function.

Thanks

Rich

0
, Richard Brown 3 years 2019-11-21T02:52:59-05:00 0 Answers 60 views 0

Leave an answer

Browse
Browse