> For the complete documentation index, see [llms.txt](https://whoisandywhite.gitbook.io/porterwp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whoisandywhite.gitbook.io/porterwp/documentation/premium-filters-block.md).

# Premium Filters Block

> Requires **PorterWP Premium**.\
> Adds faceted filtering to any **core/Query Loop**.

## Usage

1. Insert **“Filters”** block.
2. Configure filter groups via the ACF sidebar:
   * Post Types, Taxonomies, Meta, Search, Sort.
3. Add a **core/Query Loop** block *after* the Filters block and give it the CSS class **`use-filters`**.

The Filters block outputs a hidden `<form>` which serialises field choices and triggers an **AJAX refresh** handled by `Porter_Filters_Ajax_Handler`.

### File Map

| Path                                                        | Purpose                                    |
| ----------------------------------------------------------- | ------------------------------------------ |
| `includes/premium/filters/block/`                           | Block source (block.json, ACF, SCSS, JS)   |
| `core-query--use-filters.php`                               | Alters WP\_Query based on submitted params |
| `includes/premium/filters/traits/trait-FilterParser.php`    | Converts GET params ⇒ WP\_Query arguments  |
| `includes/premium/filters/traits/trait-FilterGenerator.php` | Builds HTML for facet groups               |
| `templates/`                                                | Legacy PHP templates fallback              |

***

### JavaScript lifecycle

* **assets/src/js/porter-filters.js** listens for `change` events, debounces, then calls `wp.ajax.send( 'porter_filters', … )`.
* The PHP handler returns rendered block markup which swaps the contents of the Query Loop container.

### Customising the search placeholder

If the search field is enabled, themes can override its placeholder text without replacing the filter template:

```php
add_filter( 'porter/filter/search_placeholder', function( $placeholder, $key, $post_type, $filter_settings ) {
    if ( 'resource' === $post_type ) {
        return 'Search resources';
    }

    return $placeholder;
}, 10, 4 );
```

See [porter/filter/search\_placeholder](/porterwp/filters/porter_filter_search_placeholder.md) for the full hook reference.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://whoisandywhite.gitbook.io/porterwp/documentation/premium-filters-block.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
