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

Snippet

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>';
    }
}
2 Likes

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