WooCommerce存档页面在产品标题之前添加类别

时间:2018-06-10 14:23:57

标签: php wordpress woocommerce hook-woocommerce

我需要在Woocommerce存档页面的标题之前显示产品中的类别,就像在此图像中显示的那样。 我怎么能这样做?

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用以下示例在标题上方添加类别。这个函数将进入子主题functions.php或父主题functions.php

/**
* @return add category link and title above the title or below the category
*
*/
function theme_slug_add_category_above_title() {
    global $product;
    echo wc_get_product_category_list( $product->get_id() );
}
add_action( 'woocommerce_shop_loop_item_title', 'theme_slug_add_category_above_title', 9 );

您可以在woocommerce / templates / content-product.php上获取与产品列表相关的所有挂钩列表,并且可以在woocommerce / templates / single-product / meta.php中看到wc_get_product_category_list()的使用

由于

相关问题