wpgenie icon

Custom Queries for Lotteries

wpgenie | PRO | 03/22/21 10:00:30 AM UTC | 0 ⭐ | 2513 👁️ | Never ⏰ | []
PHP |

790 B

|

None

|

0 👍

/

0 👎

/* Custom Queries for Lotteries */
/* usable when creating custom page template, not copy paste ready code - just custom query example! */
 
 
// Return active lottery products.
$args = array(
    'fields' => 'ids',
    'post_type'=> 'product',
    'show_past_lottery' => FALSE,   
    'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'lottery')),    
);     
 
// Return past lottery products.
$args = array(
    'fields' => 'ids',
    'post_type'=> 'product',
    'show_past_lottery' => TRUE,    
    'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'lottery')),            
    'meta_query' => array(
            array(
                    'key' => '_lottery_closed',
                    'operator' => 'EXISTS',             
                ),
            ),
    );          
 
$the_query  = new WP_Query( $args ); 
 

Comments