Display search results

I try to create a custom search result template but how to properly output the search results…

Use a query loop like you would if creating an archive page, leave the default query settings. Then use the template conditions (in the template settings) to make sure the template applies to ‘search results’.

2 Likes

I added this in a code block on my search results template to show the terms the user was looking for. Maybe useful for somebody.

Cheers

Patric

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

You could also just use the post title element and tick the “Add context” box.

This results in:

6 Likes