Inventory_Presser_Shortcode_Slider::get_vehicle_IDs( $shortcode_atts )
Source Source
File: includes/class-shortcode-inventory-slider.php
public static function get_vehicle_IDs( $shortcode_atts ) { $gpargs = array( 'posts_per_page' => 10, 'post_type' => INVP::POST_TYPE, 'meta_query' => array( 'relation' => 'AND', array( 'key' => apply_filters( 'invp_prefix_meta_key', 'featured' ), 'value' => 1, 'compare' => '=', ), array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS', ) ), 'fields' => 'ids', 'orderby' => $shortcode_atts['orderby'], 'order' => $shortcode_atts['order'], ); $inventory_ids = get_posts($gpargs); if (count($inventory_ids) < 10) { $gpargs = array( 'posts_per_page' => 10 - (count($inventory_ids)), 'post_type' => INVP::POST_TYPE, 'meta_query' => array( 'relation' => 'AND', array( 'relation' => 'OR', array( 'key' => apply_filters( 'invp_prefix_meta_key', 'featured' ), 'value' => array( '', '0'), 'compare' => 'IN' ), array( 'key' => apply_filters( 'invp_prefix_meta_key', 'featured' ), 'compare' => 'NOT EXISTS', ), ), array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ) ), 'fields' => 'ids', 'orderby' => $shortcode_atts['orderby'], 'order' => $shortcode_atts['order'], ); $inventory_ids += get_posts($gpargs); } if( ! $inventory_ids ) { return []; } shuffle( $inventory_ids ); return $inventory_ids; }
Expand full source code Collapse full source code View on Github