WP_Query on post modified data from within 24 hours

Question

How can I get all offices (posts) where post_modified hasn’t been updated within the last 24 hours.

I’m able to use the WP_Query call below to grab all the posts where their modified time was updated today but I want the opposite.

Here is the code:

function get_deleted_offices() {

    $day_parsed = date_parse(date("Ymd"));

    $args = array(
        'post_type'     => 'office',
        'post_status'   => 'any',
        'numberposts'   => -1,
        'date_query' => array(
            array(    // returns posts modified today
                'column' => 'post_modified',
                'year'  => $day_parsed['year'],
                'month' => $day_parsed['month'],
                'day'   => $day_parsed['day'],
            ),
        )
    );
    $office = new WP_Query($args);
    return $office->posts;
}

Here is one of the results:

array (size=10)
  0 => 
    object(WP_Post)[1319]
      public 'ID' => int 52868
      public 'post_date' => string '2019-11-06 11:25:26' (length=19)
      public 'post_date_gmt' => string '1970-01-01 00:00:00' (length=19)
      public 'post_status' => string 'publish' (length=7)
      public 'post_modified' => string '2019-11-06 11:25:26' (length=19)
      public 'post_modified_gmt' => string '1970-01-01 00:00:00' (length=19)
      public 'post_type' => string 'office' (length=6)

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/wp_query-on-post-modified-data-from-within-24-hours/">

WP_Query on post modified data from within 24 hours</a>
0
, , Sem 4 months 0 Answers 25 views 0

Leave an answer