Search

Search Forms

The {{ search }} tag creates the form behavior, while you keep control over the HTML inside it.

Basic Form#

phpresources/views/front-page.php
{{ search in="title|content" }}  <input type="search" placeholder="Search articles">  <button>Search</button>{{ /search }}

TemplateX wraps the body in a GET form. It also gives the first text-like input a name and a current value when those are missing.

Use Your Own Form Element#

If you want to write the <form> yourself, place it inside the search tag:

php
{{ search }}  <form class="site-search">    <input type="search" placeholder="Search">    <button>Search</button>  </form>{{ /search }}

TemplateX keeps your form markup and adds the missing search behavior.

Options#

OptionWhat it does
nameNames this search when more than one search exists on the page.
paramChanges the URL parameter. The default is q.
parameterSame as param.
inChooses where WordPress searches. The default is title.
search:inSame as in.

Search Areas#

Use pipes when the keyword should search more than one area:

php
{{ search in="title|content|excerpt" }}  <input type="search" placeholder="Search">  <button>Search</button>{{ /search }}

Supported areas are title, content, and excerpt.