Inventory_Presser_Plugin::modify_query_for_max_price( object $query )
Modifies the $query to filter vehicles by prices for the Maximum Price Filter widget.
On This Page
Parameters Parameters
- $query
-
(object) (Required) An instance of the WP_Query class.
Return Return
(void)
Source Source
File: inventory-presser.php
public function modify_query_for_max_price( $query ) { // Do not mess with the query if it's not the main one and our CPT. if ( ! isset( $_GET['max_price'] ) || ! $query->is_main_query() || INVP::POST_TYPE !== $query->get( 'post_type', '' ) ) { return; } // Get original meta query. $meta_query = $query->get( 'meta_query' ); if ( ! is_array( $meta_query ) ) { $meta_query = array(); } $meta_query['relation'] = 'AND'; $meta_query = self::maybe_add_meta_query( $meta_query, apply_filters( 'invp_prefix_meta_key', 'price' ), (int) $_GET['max_price'], '<=', 'numeric' ); $query->set( 'meta_query', $meta_query ); }
Expand full source codeCollapse full source codeView on Github