Site logo

[Resolved] Dynamic Search Header

Home Forums Support [Resolved] Dynamic Search Header

Home Forums Support Dynamic Search Header

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1758765
    Ivan

    Hi guys,

    I just updated to GP Premium 2.0.1 and managed to make an archive page with dynamic category names! Great!

    How can I do the same for the search page? Please see the links below. Instead of the three green dots I would like to show the search term. Additionally, I would like to remove the default box saying (Search Results for: ). Hope this will be possible.

    Thank you!

    #1760504
    Ivan

    Could you please let me know whether this can be done? Thanks!

    #1760628
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Give this a shot:

    add_filter( 'generate_dynamic_element_text', function( $text, $block ) {
        if ( is_search() && 'Your Search Title' === $block['attrs']['gpDynamicTextReplace'] ) {
            $text = get_search_query();
        }
    
        return $text;
    }, 10, 2 );

    Then you just need to update Your Search Title with the text you’ve added to the Headline block of the actual Block Element.

    Let us know 🙂

    #1760860
    Ivan

    Hi Tom,

    Thanks a lot! I thought there was something in the dynamic options that I am missing…

    Do you plan to add this to one of the next GP Premium releases? I would prefer not to add custom PHP if possible. 🙂

    Thank you!

    #1762228
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Point releases (2.0.x) are only for bug fixes, so if we do add this (seems like a good addition), it will be in 2.1.0.

    However, the above code is a filter, so it’s 100% update-safe and can simply be removed once the functionality is added to the plugin 🙂

    #1762545
    Ivan

    Thanks Tom!

    Hope you will add this to the plugin. 🙂

    Cheers,
    Ivan

    #1764116
    Tom
    Lead Developer
    Lead Developer

    Took a look at this. We’ll be adding it to 2.1.0 once GP 3.1.0 is out (as it’s not possible to remove the default search page title as of right now).

    Thanks!

    #1764217
    Ivan

    Awesome! Thank you, Tom!

    #1767731
    Tom
    Lead Developer
    Lead Developer

    No problem!

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