Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created October 27, 2016 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/26f6e6396c4a9c40d9e9b585dbd3b507 to your computer and use it in GitHub Desktop.
Save lukecav/26f6e6396c4a9c40d9e9b585dbd3b507 to your computer and use it in GitHub Desktop.
WooCommerce Product Title with SKU
/* CREATE the new function, with SKU added */
function woocommerce_template_loop_product_title_with_sku() {
global $product;
echo '<span class="loop-title-sku">' . $product->get_sku() . '</span>';
echo '<h3 class="loop-title">' . get_the_title() . '</h3>';
}
/*REMOVE old loop-title action */
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
/* ADD new loop-title-with sku action */
add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title_with_sku', 10 );
@davelow11
Copy link

This looks correct, but when adding this my functions.php it had no effect. dangelointernational.com

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