Created
November 5, 2012 07:32
-
-
Save kloon/4015808 to your computer and use it in GitHub Desktop.
WooCommerce Products Attributes shortcode
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
// Product Attributes shortcode | |
function custom_product_attr_shortcode( $atts ) { | |
if ( empty( $atts ) ) return; | |
if ( ! isset( $atts['id'] ) ) return; | |
$product = new WC_Product( $atts['id'] ); | |
$product->list_attributes(); | |
} | |
add_shortcode('product_attributes', 'custom_product_attr_shortcode'); |
looks like you have to specify "id" in the shortcode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Kloon, How exactly is this implemented? I understand how to create a shortcode, but I do not understand how I would select the specific product I want to show the attributes of. Thanks.