$query- set(meta_query

118

add_action( 'pre_get_posts', 'rc_modify_query_get_design_projects' );

function rc_modify_query_get_design_projects( $query ) {
    // Do not add meta arguments in admin pages
    if (is_admin()) {
        return;
    }

    if($query->is_main_query() && $query->query_vars['post_type'] == 'product' ) {
        //Get original meta query
        $meta_query = (array)$query->get('meta_query');

        // Add your criteria
        $meta_query[] = array(
                'key'     => 'wholesale_price',
                'value'   => 0,
                'compare' => '>',
        );    

        // Set the meta query to the complete, altered query
        $query->set('meta_query',$meta_query);
}

Comments

Submit
0 Comments