library/Content/PostFilters.php
public function doPostTaxonomyFiltering($query)
    {
        // Do not execute this in admin view
        if (is_admin() || !(is_archive() || is_home() || is_category() || is_tax() || is_tag()) || !$query->is_main_query()) {
            return $query;
        }

        $postType = $this->getPostType();
        $filterable = $this->getEnabledTaxonomies($postType, false);

        if (empty($filterable)) {
            return $query;
        }

        $taxQuery = array('relation' => 'AND');

        foreach ($filterable as $key => $value) {
            if (!isset($_GET['filter'][$key]) || empty($_GET['filter'][$key]) || $_GET['filter'][$key] === '-1') {
                continue;
            }

            $terms = (array)$_GET['filter'][$key];

            $taxQuery[] = array(
                'taxonomy' => $key,
                'field' => 'slug',
                'terms' => $terms,
                'operator' => 'IN'
            );
        }

        if (is_tax() || is_category() || is_tag()) {
            $taxQuery = array(
                'relation' => 'AND',
                array(
                    'relation' => 'AND',
                    array(
                        'taxonomy' => get_queried_object()->taxonomy,
                        'field' => 'slug',
                        'terms' => (array)get_queried_object()->slug,
                        'operator' => 'IN'
                    )
                ),
                $taxQuery
            );
        }

        $taxQuery = apply_filters('Municipio/archive/tax_query', $taxQuery, $query);

        $query->set('tax_query', $taxQuery);
        return $query;
    }
public function doPostTaxonomyFiltering($query)
    {
        // Do not execute this in admin view
        if (is_admin() || !(is_archive() || is_home() || is_category() || is_tax() || is_tag()) || !$query->is_main_query()) {
            return $query;
        }

        $postType = $this->getPostType();
        $filterable = $this->getEnabledTaxonomies($postType, false);

        if (empty($filterable)) {
            return $query;
        }

        $taxQuery = array('relation' => 'AND');

        foreach ($filterable as $key => $value) {
            if (!isset($_GET['filter'][$key]) || empty($_GET['filter'][$key]) || $_GET['filter'][$key] === '-1') {
                continue;
            }

            $terms = (array)$_GET['filter'][$key];

            $taxQuery[] = array(
                'taxonomy' => $key,
                'field' => 'slug',
                'terms' => $terms,
                'operator' => 'IN'
            );
        }

        if (is_tax() || is_category() || is_tag()) {
            $taxQuery = array(
                'relation' => 'AND',
                array(
                    'relation' => 'AND',
                    array(
                        'taxonomy' => get_queried_object()->taxonomy,
                        'field' => 'slug',
                        'terms' => (array)get_queried_object()->slug,
                        'operator' => 'IN'
                    )
                ),
                $taxQuery
            );
        }

        $taxQuery = apply_filters('Municipio/archive/tax_query', $taxQuery, $query);

        $query->set('tax_query', $taxQuery);
        return $query;
    }
public function doPostTaxonomyFiltering ( $ query ) { // Do not execute this in admin view if ( is_admin ( ) || ! ( is_archive ( ) || is_home ( ) || is_category ( ) || is_tax ( ) || is_tag ( ) ) || ! $ query -> is_main_query ( ) ) { return $ query ; } $ postType = $ this -> getPostType ( ) ; $ filterable = $ this -> getEnabledTaxonomies ( $ postType , false ) ; if ( empty ( $ filterable ) ) { return $ query ; } $ taxQuery = array ( 'relation' => 'AND' ) ; foreach ( $ filterable as $ key => $ value ) { if ( ! isset ( $ _GET [ 'filter' ] [ $ key ] ) || empty ( $ _GET [ 'filter' ] [ $ key ] ) || $ _GET [ 'filter' ] [ $ key ] === '-1' ) { continue ; } $ terms = ( array ) $ _GET [ 'filter' ] [ $ key ] ; $ taxQuery [ ] = array ( 'taxonomy' => $ key , 'field' => 'slug' , 'terms' => $ terms , 'operator' => 'IN' ) ; } if ( is_tax ( ) || is_category ( ) || is_tag ( ) ) { $ taxQuery = array ( 'relation' => 'AND' , array ( 'relation' => 'AND' , array ( 'taxonomy' => get_queried_object ( ) -> taxonomy , 'field' => 'slug' , 'terms' => ( array ) get_queried_object ( ) -> slug , 'operator' => 'IN' ) ) , $ taxQuery ) ; } $ taxQuery = apply_filters ( 'Municipio/archive/tax_query' , $ taxQuery , $ query ) ; $ query -> set ( 'tax_query' , $ taxQuery ) ; return $ query ; }
Do taxonomy fitering
@param  object $query Query object
@return object        Modified query
Do taxonomy fitering