Replace Product Search with WordPress Search
-
I would like to replace the Storefront theme’s default product search with the standard wp page/post search.
When i modified the storefront-woocommerce-template-functions.php from the storefront theme, the search is replaced and it works:function storefront_product_search() { if ( storefront_is_woocommerce_activated() ) { ?> <div class="site-search"> <!--<?php the_widget( 'WC_Widget_Product_Search', 'title=' ); ?>--> <?php the_widget( 'WP_Widget_Search', 'title=' ); ?> </div> <?php } }
but actually thats not a good way.
When I try it with my Chield Theme, it does not work, I still have the Woocommerce product search!
Content of functions.php in my chield theme:
<?php // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; // BEGIN ENQUEUE PARENT ACTION // AUTO GENERATED - Do not modify or remove comment markers above or below: if ( !function_exists( 'chld_thm_cfg_locale_css' ) ): function chld_thm_cfg_locale_css( $uri ){ if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) ) $uri = get_template_directory_uri() . '/rtl.css'; return $uri; } endif; add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' ); // END ENQUEUE PARENT //replace product search in header with site search (storefront_product_search) function child_theme_replace_header_search() { remove_action( 'storefront_header', 'storefront_product_search', 40 ); add_action( 'storefront_header', 'replacement_header_search', 40 ); } function replacement_header_search () { ?> <div class="site-search"> <?php the_widget( 'WP_Widget_Search', 'title=' ); ?> </div> <?php } add_action( 'init', 'child_theme_replace_header_search', 90 );
what i’m doing wrong?
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Replace Product Search with WordPress Search’ is closed to new replies.