Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active June 2, 2023 14:25
Show Gist options
  • Save woogists/38e9f154713998a3337c9de85e3c01ec to your computer and use it in GitHub Desktop.
Save woogists/38e9f154713998a3337c9de85e3c01ec to your computer and use it in GitHub Desktop.
[WooCommerce Brands] Add Brands to Product Loop
<?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