[Resolved] What’s the best way to show a block element on search results with no results?

Home Forums Support [Resolved] What’s the best way to show a block element on search results with no results?

Home Forums Support What’s the best way to show a block element on search results with no results?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1643406
    Samuel

    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?

    #1643431
    Ying
    Staff
    Customer Support

    Hi Samuel,

    This solution should work for you:
    https://generatepress.com/forums/topic/edit-404-page-title-and-content/#post-1638381

    Let me know ๐Ÿ™‚

    #1643449
    Samuel

    that worked perfectly–thank you!

    #1643453
    Ying
    Staff
    Customer Support

    No problem ๐Ÿ™‚

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.