Textpattern CMS Template Tags

<txp:search_result_count /> single tag, 1 attributes

search_result_count

The search_result_count tag is a single tag that returns the number of articles returned by an article tag. Use if_search to count search results or use in regular page after the article tag. If you need the results’ count before the list of results, use the article tag in conjunction with pgonly=“1” (see Example 3).

attributes

text="articles found" 
  • Text to display with the number of matches.
<txp:search_result_count /> 3 examples

Display a number of matches

<txp:if_search>
<txp:article />
<txp:search_result_count />
</txp:if_search>

What this does…
If the visitor is searching for articles, it will show the number of articles that matched the search term (e.g. 5) as follows: “5 articles found”.

Note: The if_search conditional tag is required to recognize actual search results, without them the number of articles is returned by default.

Other tags used: if_search, article

Number of matches with custom text

<txp:if_search>
<txp:search_result_count text="Hits" />
</txp:if_search />

What this does…
It displays the number of articles returned (e.g. 5) as follows: “5 Hits”.

Other tags used: if_search

Search result count above results

<txp:if_search>
<txp:article pgonly="1" limit="20" />
<txp:search_result_count text="Hits" />
<txp:article limit="20" />
</txp:if_search />

Note: The “pgonly” attribute sets the article tag to return pagination statistics without rendering the article list. Care must be taken to remain consistent with article tag attributes to keep statistics accurate.

Other tags used: article, if_search