Advertisement
wpgenie

Custom Queries for Lotteries

Mar 22nd, 2021
1,139
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Custom Queries for Lotteries */
  2. /* usable when creating custom page template, not copy paste ready code - just custom query example! */
  3.  
  4.  
  5. // Return active lottery products.
  6. $args = array(
  7.     'fields' => 'ids',
  8.     'post_type'=> 'product',
  9.     'show_past_lottery' => FALSE,  
  10.     'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'lottery')),   
  11. );    
  12.  
  13. // Return past lottery products.
  14. $args = array(
  15.     'fields' => 'ids',
  16.     'post_type'=> 'product',
  17.     'show_past_lottery' => TRUE,   
  18.     'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'lottery')),           
  19.     'meta_query' => array(
  20.             array(
  21.                     'key' => '_lottery_closed',
  22.                     'operator' => 'EXISTS',            
  23.                 ),
  24.             ),
  25.     );          
  26.  
  27. $the_query  = new WP_Query( $args );
  28.  
Advertisement
RAW Paste Data Copied
Advertisement