Site logo

Archived topic

Output of the search term in Elements "page hero"

3 replies · Started by Stefanie on February 16, 2023

Viewing posts 1–4 of 4

Hi there,

I discovered this code to create a shortcode that outputs the search term. Now I tried to insert this shortcode in my block element "page hero" to create an output like this:

You have searched for ...

But in the page-hero element I get this error message when I try to paste the shortcode there:
Update failed. The response is not a valid JSON response.

Is there a better way to output the search term dynamically in page hero?

Hi there,

add this PHP snippet to create the [search_term] shortcode

add_shortcode('search_term', function(){
    return get_search_query();
});

You can then add that in a GB Headline block with text before ( and/or after it ).

again super helpful 👍👍👍

Thank you!

You're welcome

This archived topic is closed to new replies.