Skip to content

Instantly share code, notes, and snippets.

@lawkwok
Created May 13, 2015 23:53
Show Gist options
  • Save lawkwok/4147c1a009f76f321e58 to your computer and use it in GitHub Desktop.
Save lawkwok/4147c1a009f76f321e58 to your computer and use it in GitHub Desktop.
Add brand name above product title in archive pages
<?php
// Gets the name of the brand
function output_brand() {
$terms = get_the_terms( $post->ID , 'brand' );
if ( empty($terms) == false ) {
foreach ( $terms as $term ) {
return $term->name;
}
} else return null;
}
// Adds brand name of product above title in archive pages
add_action( 'woocommerce_before_shop_loop_item_title', 'brand_in_title' );
function brand_in_title() {
echo '<h3 class="brand">' . output_brand() . '</h3>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment