dimanche 5 juin 2016

Wordpress Woocommerce adding a search field to a hook

I am trying to add the woocommerce search widget into the woocommerce_before_shop_loop hook. I'm fairly new to modifying hooks, and from my understanding it should be done in the child theme's functions.php. I added the following code to my functions.php to achieve this:

add_action( 'woocommerce_before_shop_loop', 'add_shop_search', 10 );
function add_shop_search() {
    if ( function_exists( 'woocommerce_product_search' ) ) { 
        echo woocommerce_product_search(); 

    }
    else {
        echo 'not exists';
    }

but I get the 'not exists' when I view the page. woocommerce_product_search() should exist according to the woocommerce documentation so I am unsure as to why this method doesn't work. am I going about this the wrong way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire