Smallest Search#
Put a {{ search }} form before the query it should control:
{{ search }} <input type="search" placeholder="Search posts"> <button>Search</button>{{ /search }}{{ query:posts search }} <article> <h2><a href="{{ url }}">{{ title }}</a></h2> </article>{{ /query:posts }}The search form reads the keyword from the URL. The query loop uses that keyword when it asks WordPress for posts.
Defaults#
By default, {{ search }}:
- creates a GET form
- uses the URL parameter
q - searches post titles
- fills the input with the current search value