[Resolved] Change Search Parameters in Navigation Menu?

Home Forums Support [Resolved] Change Search Parameters in Navigation Menu?

Home Forums Support Change Search Parameters in Navigation Menu?

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #51334
    Robyn Williams

    Hey there! Loving the theme – I’m currently working on a WooCommerce site and have implemented a custom GeneratePress child theme.

    I love the search button in the main navigation bar – however, it searches ALL posts, pages AND products. I would just like it to search products only.

    I’ve done some research in the WordPress support forms, but haven’t found exactly what I need yet. (Perhaps I’m looking in the wrong place…) I’m currently looking at the GP theme’s searchform.php file to see if anything looks familiar.

    I would greatly appreciate any help. Thanks so much!

    #51405
    Tom
    Lead Developer
    Lead Developer

    Hi Robyn,

    Let me look into this – I’ll try and provide a solution for you in the morning.

    Thanks!

    #51654
    Tom
    Lead Developer
    Lead Developer

    Alright, here’s the solution πŸ™‚

    add_filter( 'generate_navigation_search_output', 'tu_wc_navigation_search' );
    function tu_wc_navigation_search() {
    	printf(
    		'<form method="get" class="search-form navigation-search" action="%1$s">
    			<input type="search" class="search-field" value="%2$s" name="s" title="%2$s">
    			<input type="hidden" name="post_type" value="product">
    		</form>',
    		esc_url( home_url( '/' ) ),
    		esc_attr( get_search_query() ),
    		esc_attr_x( 'Search', 'label', 'generatepress' )
    	);
    }

    Hope this helps πŸ™‚

    #51659
    Robyn Williams

    It worked!!

    Tom, you are so awesome. Thanks so much for the help and the quick response!

    #69706
    Kris Tengberg

    Hello Tom,

    I am enjoying the GeneratePress Theme and the Add-Ons immensely! You have my endless gratitude and praise. And I am equally pleased by the Tutorials and Support you offer.

    I hope this piggyback post is not too far off the subject under discussion. I despise Topic Drift as much as I do Excess Thread Starting. πŸ™‚

    Request:
    I would also like to remove Search from the main Navigation bar, but not replace it.

    Where is the code and what exactly do I delete (or comment out because you never know…) to remove the Default Search function from the Nav bar only?

    I would still like to use the sidebar Search widget.

    Thank you,

    Kris

    #69707
    Kris Tengberg

    Hello again Tom,

    Please disregard the questions and keep the praise. πŸ™‚
    I don’t know how I kept missing the selection in the Layout part of the Customization menu.
    Glad for that great Knowledgebase!

    Thank you,

    Kris

    #69754
    Tom
    Lead Developer
    Lead Developer

    Hi Kris,

    Glad you found the option!

    For others, the option is in “Appearance > Customize > Layout”.

    Thanks!

    #141333
    Rylan

    I have an additional request! Can you make the search box appear UNDER the navigation instead of over of it. It’s mighty confusing and crowded when you can see menu text and menu image under the search text. Also maybe a button to search so if people don’t know to push enter, there is another option. But i think my first request is vital!

    Thanks,

    Rylan

    #141345
    Tom
    Lead Developer
    Lead Developer

    Hi Rylan,

    You can make it appear below with this CSS (compatible with the sticky menu add-on):

    .main-navigation:not(.navigation-clone) .navigation-search {
        top: 60px;
    }

    60px is the height of your menu items (this can be adjusted if you’ve changed it).

    Adding a button is a bit harder, but I may add a placeholder explaining to type your search and hit enter or something in the near future πŸ™‚

    #160001
    Patrick

    Hey there,

    my website is growing and I really enjoy working with GP. But I got to a point where I am lost now. I try to change the text of the search function from “Search…” to “Suche…” (German translation). So far I tried to modify the searchform.php and search.php in the template folder but nothing worked so far.

    When I rename searchform.php to old.searchform.php I get the german version with “Suchen…”?

    Can you help me, please? πŸ™‚

    #160066
    Tom
    Lead Developer
    Lead Developer

    Are you using a child theme with a searchform.php file or are you using the function above?

    #160198
    Patrick

    I am not sure but I don’t think that I am using a child theme – at least there is none active :-/

    #160324
    Tom
    Lead Developer
    Lead Developer

    By default, that text should already be translated to German.

    I just tested it on my testing site and it was indeed translated?

    Are you aware of any custom functions you’ve added if you don’t have a child theme?

    #160702
    Patrick

    Not really, no. But I renamed searchform.php to old.searchform.php and now I have the german translation…

    #160806
    Tom
    Lead Developer
    Lead Developer

    You renamed searchform.php in the main “wp-content/themes/generatepress” folder?

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