Created
May 13, 2015 23:53
-
-
Save lawkwok/4147c1a009f76f321e58 to your computer and use it in GitHub Desktop.
Add brand name above product title in archive pages
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 | |
// 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