Site logo

[Resolved] Output of the search term in Elements “page hero”

Home Forums Support [Resolved] Output of the search term in Elements “page hero”

Home Forums Support Output of the search term in Elements “page hero”

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2535215
    Stefanie

    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?

    #2535704
    David
    Staff
    Customer Support

    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 ).

    #2535864
    Stefanie

    again super helpful 👍👍👍

    Thank you!

    #2536611
    David
    Staff
    Customer Support

    You’re welcome

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