mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-04 12:22:24 +08:00
https://woocommerce.com/document/managing-product-taxonomies/product-brands/#add-brands-to-product-loop
13 lines
487 B
Text
13 lines
487 B
Text
if ( is_plugin_active( 'woocommerce-brands/woocommerce-brands.php' ) ) {
|
|
|
|
add_action( 'woocommerce_shop_loop_item_title', 'add_brands_to_product_loop' );
|
|
|
|
// Add brands to product loop.
|
|
function add_brands_to_product_loop() {
|
|
$terms = get_the_terms( get_the_ID(), 'product_brand' );
|
|
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
|
|
$term = join( ', ', wp_list_pluck( $terms, 'name' ) );
|
|
echo esc_html( $term );
|
|
}
|
|
}
|
|
}
|