Skip to content

Instantly share code, notes, and snippets.

@woogist
Created July 20, 2015 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woogist/2287a29b2589776ec4fb to your computer and use it in GitHub Desktop.
Save woogist/2287a29b2589776ec4fb to your computer and use it in GitHub Desktop.
/**
* Print the product's vendor name before the product title in the loop.
*
* @return void
*/
function wc_vendors_name_loop() {
$vendors = get_the_terms( get_the_ID(), 'shop_vendor' );
if ( $vendors && ! is_wp_error( $vendors ) ) {
foreach ( $vendors as $vendor ) {
$all_vendors[] = '<a href="' . get_term_link( $vendor, 'shop_vendor' ) . '" title="' . $vendor->name . '">' . $vendor->name . '</a>';
}
$vendors = join( ", ", $all_vendors );
echo '<span class="shop_vendors">' . $vendors . '</span>';
}
}
add_action( 'woocommerce_before_shop_loop_item_title', 'wc_vendors_name_loop', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment