Site logo

Archived topic

Navigation Search by SKU

1 reply · Started by Jeff on May 31, 2019

Viewing posts 1–2 of 2

I am using the code snippet below that I found in the forums to make the default nav search include products only. However, I cannot seem to search by SKU number. Is there something I can add to make this field use SKU as an additional WooCommerce searchable field.

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' ) 
    ); 
} );

Thanks!

This archived topic is closed to new replies.