Search

Filter Controls

Filter controls let a search form render taxonomy terms as selectable inputs.

Generated Control#

Use a single {{ filter:* }} tag when the default markup is enough:

phpresources/views/front-page.php
{{ search auto }}  <input type="search" placeholder="Search">  {{ filter:category type="select" }}{{ /search }}{{ query:posts search }}  <h2><a href="{{ url }}">{{ title }}</a></h2>{{ /query:posts }}

The query only needs search. TemplateX applies the selected filter values from the matching search form.

Control Types#

Use the type option to choose the generated control:

  • {{ filter:category type="select" }}
  • {{ filter:category type="checkbox" }}
  • {{ filter:category type="radio" }}
  • {{ filter:category type="pill" }}

Generated controls are plain HTML. Style them in your theme CSS.

Taxonomy Names#

Use the taxonomy name after filter:.

  • {{ filter:category }}
  • {{ filter:post_tag }}
  • {{ filter:project_type }}

TemplateX stores selected terms in URL parameters such as filter_category and filter_post_tag.