Site logo

[Resolved] Custom search trigger button

Home Forums Support [Resolved] Custom search trigger button

Home Forums Support Custom search trigger button

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2518924
    Daniel

    Hi there!

    I need to create a custom button that, when clicked, will load the GeneratePress search form. I need to put that search button in a block inside Gutenberg.

    I want to know if that is possible. To create a button with a specific class or to use a shortcode to generate the GP search button and be able to place it inside a Gutenberg block.

    Any other system that you recommend me and that I can include inside a Gutenberg block can be useful to me.

    Thanks!

    #2518931
    Ying
    Staff
    Customer Support

    Hi Daniel,

    Do you consider using the WP search block?

    #2518944
    Daniel

    Hi Ying,

    What I need is a button or something like the magnifier icon GP adds to the main menu that when clicked opens the search form template.

    The WP search block is a search input and a search button. I can’t use that block for what I want to achieve.

    #2518969
    Ying
    Staff
    Customer Support

    Where are you going to place the button? There’s no easy way to use just a class to achieve this.

    Let me know!

    #2519031
    Daniel

    I need it for use within Gutenberg.
    I don’t care if it is a button, an icon or a shortcode that I can use to call the search template.

    I don’t know if in GP there is a function that generates the search button/icon. If there is such a function, maybe I can build it into a shortcode to display it where I need it.

    #2519125
    Ying
    Staff
    Customer Support

    You can give this code a try, using the [gp_navigation_search] shortcode.

    function generate_navigation_search_shortcode() {
      // Call the theme's built-in function
      $navigaion_button = generate_do_navigation_search_button(); 
      $search_form = generate_navigation_search();
      $output = $navigaion_button .$search_form;
    
       echo $output;
     
    }
    add_shortcode( 'gp_navigation_search', 'generate_navigation_search_shortcode' );
    #2519749
    Daniel

    Thanks for the code, Ying.

    Unfortunately, once I added the code to functions.php and inserted the shortcode, nothing is generated on the page.

    Anyway, I have found a workaround to achieve what I needed, so I’ve got it solved.

    #2520400
    Ying
    Staff
    Customer Support

    Glad to hear that 🙂

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