Created
July 24, 2013 08:42
-
-
Save agusmu/6068952 to your computer and use it in GitHub Desktop.
WooCommerce - Adding category, excerpt, and SKU to shop page
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
/* Adding category, excerpt, and SKU to shop page */ | |
add_action( 'woocommerce_after_shop_loop_item', 'prima_custom_shop_item', 5); | |
function prima_custom_shop_item() { | |
global $post, $product; | |
/* product categories */ | |
$size = sizeof( get_the_terms( $post->ID, 'product_cat' ) ); | |
echo $product->get_categories( ', ', '<p>' . _n( 'Category:', 'Categories:', $size, 'woocommerce' ) . ' ', '.</p>' ); | |
/* product excerpt */ | |
if ( $post->post_excerpt ) { | |
echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ); | |
} | |
/* product sku */ | |
echo '<p>SKU: '.$product->get_sku().'</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tutorial: http://www.primathemes.com/documentation/adding-category-excerpt-and-sku-to-shop-page/