Чтобы получить теги брендов YITH для текущего продукта в подключенной функции, вы будете использовать:
// Get the YITH brands tags (array of term names)
$brands = wp_get_post_terms( get_the_id(), 'yith_product_brand', array( 'fields' => 'names' ) );
// Convert the array to a string (with coma separated brand tags)
$brands = implode(', ', $brands);
или, если у вас есть уникальный бренд, установленный по продукту, вы будете использовать:
// Get the YITH brands tags (array of term names)
$brands = wp_get_post_terms( get_the_id(), 'yith_product_brand', array( 'fields' => 'names' ) );
// Convert the array to a string
$brand = reset($brands);
Теперь вы можете легко включить этот код в подключенную функцию, чтобы заменить текст «читать дальше»:
add_action( 'woocommerce_after_shop_loop_item', 'zn_woocommerce_more_info' );
function zn_woocommerce_more_info(){
echo '<span class="kw-actions">';
$brands = wp_get_post_terms( get_the_id(), 'yith_product_brand', array( 'fields' => 'names' ) );
$brand = reset($brands);
echo '<a class="actions-moreinfo" href="'.get_permalink().'" title="'. $brand .'">';
if ( zget_option( 'woo_prod_layout', 'zn_woocommerce_options', false, 'classic' ) == 'style2' ) {
echo '<svg width="50px" height="24px" class="svg-moreIcon"><circle cx="12" cy="12" r="2"/><circle cx="20" cy="12" r="2"/><circle cx="28" cy="12" r="2"/></svg>';
} else {
echo $brand;
}
echo '</a>';
echo '</span>';
}
Если вы используете плагин Woocommerce Brands ,Вам придется заменить в коде 'yith_product_brand'
на 'product_brand'
.Вот и все.
Соответствующий ответ: Показать категорию и название бренда на странице одного продукта