2019-11-12By Jose Luis Iñigo (Riskoo)

wordpress blog 2

Añadir a function.php

/**

* Move WooCommerce subcategory list items into

* their own  separate from the product .

*/

add_action( 'init', 'move_subcat_lis' );

function move_subcat_lis() {

// Remove the subcat s from the old location.

remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );

add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_start', 1 );

add_action( 'woocommerce_before_shop_loop', 'msc_maybe_show_product_subcategories', 2 );

add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_end', 3 );

}

/**

* Conditonally start the product loop with a  contaner if subcats exist.

*/

function msc_product_loop_start() {

$subcategories = woocommerce_maybe_show_product_subcategories();

if ( $subcategories ) {

woocommerce_product_loop_start();

}

}

/**

* Print the subcat s in our new location.

*/

function msc_maybe_show_product_subcategories() {

echo woocommerce_maybe_show_product_subcategories();

}

/**

* Conditonally end the product loop with a  if subcats exist.

*/

function msc_product_loop_end() {

$subcategories = woocommerce_maybe_show_product_subcategories();

if ( $subcategories ) {

woocommerce_product_loop_end();

}

}