wpgenie

Custom Queries for Lotteries

Mar 22nd, 2021
519
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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×