Skip to content

Instantly share code, notes, and snippets.

@kloon
Created November 5, 2012 07:32
Show Gist options
  • Save kloon/4015808 to your computer and use it in GitHub Desktop.
Save kloon/4015808 to your computer and use it in GitHub Desktop.
WooCommerce Products Attributes shortcode
// 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');
@jefmcclimans
Copy link

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.

@Artistan
Copy link

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