mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-03 12:12:25 +08:00
https://wordpress.stackexchange.com/questions/344386/display-woocommerce-size-product-attribute-on-shop-page
9 lines
320 B
Text
9 lines
320 B
Text
add_action( 'woocommerce_after_shop_loop_item_title', '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>';
|
|
}
|
|
}
|