Advertisement
DidouS

removing term 'just-confirmed' from events

Sep 30th, 2019
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1. <?php
  2.  
  3.         // update the events that have a publish status only
  4.         $args = array(
  5.                 'post_type' => 'event',
  6.                 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'),
  7.                 'numberposts' => -1,
  8.                 'suppress_filters' => 0,
  9.         );
  10.  
  11.  
  12.         /**
  13.          * Since we need to match either one of the meta_queries, set the relation to OR
  14.          */
  15.         if ( !isset( $args['meta_query'] ) ) $args['meta_query'] = array( 'relation' => 'OR' );
  16.  
  17.  
  18.         /**
  19.          * NEED This one to select the ones that have recieved a UNIX timestamp at post creation
  20.          */
  21.         $args['meta_query'] = array_merge(
  22.             $args['meta_query'] ,
  23.             array(
  24.                 array(
  25.                     'relation' => 'AND',
  26.                        array(
  27.                          'key' => 'import_date',
  28.                          'value' => date( 'U' , strtotime("-7 days") ),
  29.                          'type' => 'NUMERIC',
  30.                          'compare' => '<='
  31.                        ),
  32.                     ),
  33.                 ),
  34.         );
  35.  
  36.         /**
  37.          * This one is needed to select the ones that have been updated or created through the dashboard with an ACF value
  38.          */
  39.         $args['meta_query'] = array_merge(
  40.             $args['meta_query'] ,
  41.             array(
  42.                 array(
  43.                     'relation' => 'AND',
  44.                        array(
  45.                          'key' => 'import_date',
  46.                          'value' => date( 'Ymd' , strtotime("-7 days") ),
  47.                          'type' => 'DATE',
  48.                          'compare' => '<='
  49.                        ),
  50.                     ),
  51.                 ),
  52.         );
  53.  
  54.         /**
  55.          * Get the ones that have a ticketstatus of 'just-confirmed'
  56.          */
  57.         $args['tax_query'] = array(                    
  58.             'relation' => 'AND',                      
  59.                 array(
  60.                     'taxonomy' => 'ticketstatus',
  61.                     'field' => 'slug',
  62.                     'terms' => array( 'just-confirmed' ),
  63.                     'include_children' => true,
  64.                     'operator' => 'IN',
  65.                 ),
  66.         );
  67.  
  68.         $events = get_posts( $args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement