Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joedooley/5e2b6eed1b3a0871d66f to your computer and use it in GitHub Desktop.
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
<?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