Skip to content

Instantly share code, notes, and snippets.

@WPprodigy
Created January 30, 2017 22:11
Show Gist options
  • Save WPprodigy/d01f997822cf4931ec116b3d67ac2aaa to your computer and use it in GitHub Desktop.
Save WPprodigy/d01f997822cf4931ec116b3d67ac2aaa to your computer and use it in GitHub Desktop.
Add brands listing underneath products on archive pages: http://cld.wthms.co/6ud1/586aeCgL
add_action( 'woocommerce_after_shop_loop_item', 'wc_ninja_add_brands_to_archives', 6 );
function wc_ninja_add_brands_to_archives() {
global $post;
$brand_count = sizeof( get_the_terms( $post->ID, 'product_brand' ) );
$taxonomy = get_taxonomy( 'product_brand' );
$labels = $taxonomy->labels;
echo get_brands( $post->ID, ', ', ' <div class="posted_in">' . sprintf( _n( '%1$s: ', '%2$s: ', $brand_count ), $labels->singular_name, $labels->name ), '</div>' );
}
@lavalldesign
Copy link

Good!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment