How do I display (or render in twig) the search term, entered in the search field. When you enter a search term and click on the search button, you will go to the search results page (view).

In the header of that view I want to display something like:

Your search of [mysearcherm] has x number of results.

I build the search field with a views exposed form and Search API.

Update: In the textarea of the views header I want to insert the search term as replacement token, but it's not available?

2 Answers 2


You can show the relevant search term in Text area when you add it to the Header option in Views.

When you tick the Use replacement tokens from the first row option you will see the Replacement patterns tokens available, and below that global replacement tokens.

You can use something like:

<div class="messages messages--status">Your search of {{ name }} has [view:total-rows] result(s). </div>

Although you'll probably want to take care of plurals more intelligently and also use a twig conditional to not show anything if the Exposed form isn't used.

  • 1
    ok good idea, but the token for the search term is not available..?
    – meez
    Sep 24, 2019 at 20:12
  • Can you update your question with the Exposed filter config and the Text area tokens?
    – prkos
    Sep 24, 2019 at 21:01

You could use the global replacement pattern for the current page query parameter.

E.g. for /search?search_term_field_name=foo:

  • This is just a workaround because it isn't a direct reference to the views exposed filter. There might be a better solution. May 2, 2022 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.