Last active
October 25, 2015 06:49
-
-
Save joedooley/5e2b6eed1b3a0871d66f to your computer and use it in GitHub Desktop.
* Add Brand taxonomy link to Single Product page * Add Brand taxonomy link to Single Product page * Add Brand taxonomy link to Single Product page
Add Brand taxonomy link to Single Product page before meta
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 | |
add_action('woocommerce_product_meta_start', 'my_woocommerce_after_single_product' ); | |
/** | |
* Add Brand taxonomy link to Single Product page | |
* @author Joe Dooley | |
* | |
*/ | |
function my_woocommerce_after_single_product () { | |
if is_product() { | |
$brand_prefix = 'Brand:'; | |
$terms = get_the_terms( get_the_ID(), 'product-brand' ); | |
if ( $terms && ! is_wp_error( $terms ) ) { | |
$brand = $terms[0]; | |
} | |
echo '<span class="single-product-brand">' . $brand_prefix . '</span>'; | |
printf( '<a class="single-product-brand-link" href="%s">%s</a><br>', get_term_link( $brand ), $brand->name ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment