【发布时间】:2016-07-16 17:01:57
【问题描述】:
我已经掌握了一些逻辑,但正在与如何实施作斗争:
- 仅在特定产品类别中的产品上显示我的自定义产品计数
- 还仅在特定的自定义 WP 页面上显示产品数量(我使用了
product_category短代码)
我在functions.php中的代码如下,它确实在产品缩略图之前添加了$top50_counter值,但它是在整个站点范围内进行的,因此为什么我需要根据上述观点缩小范围。
/* ADD NUMBERING TO TOP 50 LIST PRODUCTS */
add_action( 'woocommerce_before_shop_loop_item_title', 'custom_before_shop_loop_item', 5);
$top50_counter=1;
function custom_before_shop_loop_item() {
global $top50_counter;
echo '<h1>'.$top50_counter.'</h1>';
$top50_counter++;
}
我假设我必须以某种方式使用其中的$terms = get_the_terms 函数?
【问题讨论】:
标签: woocommerce counter categories product shortcode