Dynamic title on the search result page

Hi

Is there currently a way to dynamically display the title on the search result page?
For example, a user searches for the term “bricks”. On the search results page, the title is updated based on the user’s search term. There should be a DD Tags for it. But I can’t find anything. I am right?

Thanks in advance

Yes, add a code element and enter this litte code:

<?php
echo '<h4 class="title">' . esc_html__( 'Results for: "', 'bricks' ) . get_search_query() .'"</h4>';
?>

or even easier, a heading element with this:

search

Results: {echo:get_search_query()}

Cheers

Patric

2 Likes

Hi @Patric,

Thanks for the great solution my friend.

Better option use just {search_term} than custom code.
{search_term} Outputs current search term and {post_title} outputs current category. Use conditions to use the same template for archives and search. I think its cleaner that way.

Also use {query_results_count_filter:41a0ab} “41a0ab“ its your element id that hold de query, to ouput the number or results ajax.

Condition to show title on search

image

Condition to show category name and not search term.

image

Hope this helps :grin: