Basic Syntax#
{{ query:posts }} <article> <h2><a href="{{ url }}">{{ title }}</a></h2> <p>{{ excerpt }}</p> </article>{{ /query:posts }}The markup inside the loop repeats once for each post.
How It Works#
Inside the loop, values belong to the current result.
{{ query:posts }} <h2>{{ title }}</h2>{{ /query:posts }}If WordPress finds posts, TemplateX prints one heading for each post.
Limit Results#
Use limit when you want to cap the number of results:
{{ query:posts limit="3" }} <h2>{{ title }}</h2>{{ /query:posts }}Without pagination, limit="3" means the query prints up to 3 posts total.
With pagination, limit becomes the page size. For example, limit="12" paginate means 12 posts per page.
Empty Results#
Use {{ else }} when WordPress finds no posts:
{{ query:posts }} <h2>{{ title }}</h2>{{ else }} <p>No posts found.</p>{{ /query:posts }}The first part repeats for each result. The else part renders only when the query is empty.