Last active
June 2, 2023 14:25
-
-
Save woogists/38e9f154713998a3337c9de85e3c01ec to your computer and use it in GitHub Desktop.
[WooCommerce Brands] Add Brands to Product Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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 ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment