Created
July 20, 2015 07:14
-
-
Save woogist/2287a29b2589776ec4fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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