src/class-extended-cpt.php
public function maybe_filter( WP_Query $wp_query ) {

		if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->post_type, (array) $wp_query->query['post_type'], true ) ) {
			return;
		}

		$vars = self::get_filter_vars( $wp_query->query, $this->args['site_filters'] );

		if ( empty( $vars ) ) {
			return;
		}

		foreach ( $vars as $key => $value ) {
			if ( is_array( $value ) ) {
				$query = $wp_query->get( $key );
				if ( empty( $query ) ) {
					$query = [];
				}
				$value = array_merge( $query, $value );
			}
			$wp_query->set( $key, $value );
		}

	}
public function maybe_filter( WP_Query $wp_query ) {

		if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->post_type, (array) $wp_query->query['post_type'], true ) ) {
			return;
		}

		$vars = self::get_filter_vars( $wp_query->query, $this->args['site_filters'] );

		if ( empty( $vars ) ) {
			return;
		}

		foreach ( $vars as $key => $value ) {
			if ( is_array( $value ) ) {
				$query = $wp_query->get( $key );
				if ( empty( $query ) ) {
					$query = [];
				}
				$value = array_merge( $query, $value );
			}
			$wp_query->set( $key, $value );
		}

	}
public function maybe_filter ( WP_Query $ wp_query ) { if ( empty ( $ wp_query -> query [ 'post_type' ] ) || ! in_array ( $ this -> post_type , ( array ) $ wp_query -> query [ 'post_type' ] , true ) ) { return ; } $ vars = self :: get_filter_vars ( $ wp_query -> query , $ this -> args [ 'site_filters' ] ) ; if ( empty ( $ vars ) ) { return ; } foreach ( $ vars as $ key => $ value ) { if ( is_array ( $ value ) ) { $ query = $ wp_query -> get ( $ key ) ; if ( empty ( $ query ) ) { $ query = [ ] ; } $ value = array_merge ( $ query , $ value ) ; } $ wp_query -> set ( $ key , $ value ) ; } }
Set the relevant query vars for filtering posts by our front-end filters.

@param WP_Query $wp_query The current WP_Query object.
Set the relevant query vars for filtering posts by our front - end filters .