Site logo

Archived topic

Show product search in archive/shop page format

4 replies · Started by Richard on March 1, 2020

Viewing posts 1–5 of 5

Hi!

I want ask for helo with how the search form shows the result. I want to show all the result (even if it's only one) in the archive page format, I use the filter:

add_filter( 'generate_navigation_search_output', function() {
    printf(
        '<form method="get" class="search-form navigation-search" action="%1$s">
            <input type="search" placeholder="Enter your 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' ) 
    ); 
} );

But when is only one result, it directly re-direct to the product page and what I want is to show that product on archive page (because my shop doesn't have product page).

Thank you for your help!

Some help please?

Hi there,

Just looked around and found this filter:

add_filter( 'woocommerce_redirect_single_search_result', '__return_false' );

Let me know if it helps or not :)

Works perfectly.

Thank you Tom!

You're welcome :)

This archived topic is closed to new replies.