[Resolved] The search engine shows me the products as blog entries and not as a shop

Home Forums Support [Resolved] The search engine shows me the products as blog entries and not as a shop

Home Forums Support The search engine shows me the products as blog entries and not as a shop

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #981830
    Gisbert A.

    hello, The search engine of my page shows me the products as blog entries and not as a shop.

    When I use another template I do well, but when one search engine in the generatepress template, it shows me listings of products one below the other as if they were entries.

    I am using generatepress PREMIUM, ELEMENTOR PRO and WOOCOMERCE

    #981838
    David
    Staff
    Customer Support

    Hi there,

    this document provides a PHP snippet to make the Nav Search output Woocommerece instead of the default WP search

    https://docs.generatepress.com/article/generate_navigation_search_output/#woocommerce-products

    #981851
    Gisbert A.

    Can you be more specific?
    There are many. If you know what it is I would appreciate it very much if you can tell me the name or even put a direct link to which is.

    Thank you for your help.

    #981867
    David
    Staff
    Customer Support
    #981875
    Gisbert A.

    Okay, thanks. I guess this’ll figure it out.

    One last question, do I put it directly in the search.php file of your template or does it go in another file?

    Is it just copy and paste? or does it have to go somewhere?

    thank you

    #981886
    David
    Staff
    Customer Support

    This article explains how to add PHP:

    https://docs.generatepress.com/article/adding-php/

    It should go into your child themes function.php or use the code snippets plugin to add it, a link to the plugin is included in the above article

    #981895
    Gisbert A.

    Thank you very much for your help, it’s already solved.

    Copy the code:

    add_filter( ‘generate_navigation_search_output’, function() {
    printf(
    ‘<form method=”get” class=”search-form navigation-search” action=”%1$s”>
    <input type=”search” class=”search-field” value=”%2$s” name=”s” title=”%3$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’ )
    );
    } );

    into the functions.php file and it already works.

    #981896
    David
    Staff
    Customer Support

    Glad to be of help

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