I've noticed that my WooCommerce products are not searched by the default WordPress search function. Any idea how to modify the function to ensure that products and product tabs are searched?
Just extend your search form with a hidden input: (notice the last input field)
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>"> <label> <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span> <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" /> </label> <input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" /> <input type="hidden" value="product" name="post_type" id="post_type" /> </form>
I'm running several WooCommerce sites, and the WordPress search does include products along with posts/pages. Do you have a custom
search.php file or any custom functions that would alter the products taxonomy to exclude it from search? WooCommerce also has a product widget that can be used as well.