Archived topic
What's the best way to show a block element on search results with no results?
3 replies · Started by Samuel on February 2, 2021
I want to use a block element to add some custom content when a search produces no results. I know I can change the no-results.php template, but I would like to make the change without creating a custom template file (I'm using a child theme so this is an option).
Pretty much all the hooks I can use will display whether there are results or no results and there is no location selection for a search with no results. Obviously I could use css to only show the html if there are no results but I'd like to not generate the block unless there are results. Is there an easy way to determine if the block should show without modifying the no-results template?
Hi Samuel,
This solution should work for you:
https://generatepress.com/forums/topic/edit-404-page-title-and-content/#post-1638381
Let me know :)
that worked perfectly--thank you!
No problem :)