【发布时间】:2021-04-07 22:36:34
【问题描述】:
我正在尝试根据特定产品属性“pa_kolekcja”术语值(在产品上设置)显示相关产品。我有以下一段代码(几乎准备好了):
function woo_related_products_edit() {
global $product;
$current_kolekcja = "???"; // <== HERE
$args = apply_filters( 'woocommerce_related_products_args', array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'no_found_rows' => 1,
'posts_per_page' => 4,
'orderby' => $orderby,
'post__not_in' => array( $product->id ),
'tax_query' => array(
array(
'taxonomy' => 'pa_kolekcja',
'field' => 'slug',
'terms' => $current_kolekcja
)
)
) );
}
add_filter( 'woocommerce_related_products_args', 'woo_related_products_edit' );
如何获取产品上设置的当前产品属性“pa_kolekcja”术语值?
【问题讨论】:
标签: php wordpress woocommerce custom-taxonomy taxonomy-terms