Display Product Attribute on the Product Page in WooCommerce

Use this code snippet to display a product attribute on the product page in WooCommerce on child sites.

Snippet Type

Execute on Child Sites


add_action( 'woocommerce_single_product_summary', 'display_size_attribute', 5 );
function display_size_attribute() {
    global $product;

    if ( $product->is_type('variable') ) {
        $taxonomy = 'pa_size';
        echo '<span class="attribute-size">' . $product->get_attribute($taxonomy) . '</span>';

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.