我正在尝试在Woocommerce类别存档页面中显示自定义字段 在我的函数php中,创建我的术语prix_min_cat并保存。及其在相同的页面中工作,但没有循环。
add_action( 'woocommerce_after_subcategory_title', 'custom_add_catg_min_price', 12);
function custom_add_catg_min_price ($category) {
$cat_id = $category->term_id;
$prod_term = get_term($cat_id,'product_cat');
$minprice= $prod_term->prix_min_cat;
echo '<p class="showcase-item-addendum">'.$minprice.'</p>';
}
我如何显示我的期限值
答案 0 :(得分:0)
您可以调整此代码以显示术语值:
add_action( 'woocommerce_after_subcategory_title', 'wpm_product_cat_display_details_meta' );
/**
* Display details meta on Product Category archives.
*
*/
function wpm_product_cat_display_details_meta() {
if ( ! is_tax( 'product_cat' ) ) {
return;
}
$t_id = get_queried_object()->term_id;
$details = get_term_meta( $t_id, 'details', true ); //'details' is your term value
if ( '' !== $details ) { //'details' is your term value
?>
<div class="product-cat-details">
<?php echo apply_filters( 'the_content', wp_kses_post( $details ) ); ?> //'details' is your term value
</div>
<?php
}
}
您应该能够对此进行调整以使其起作用。否则,这是来源:http://www.wpmusketeer.com/add-a-wysiwyg-field-to-woocommerce-product-category-page/