I'm trying to display the attributes of the current product. In the screenshot below, I declared the attribute "Liquor Brands" and assigned multiple values to it:
Here is the code I'm currently working on:
<?php
$liquor = new WP_Query( array(
'post_type' => 'product',
'product_cat' => 'liquors',
'meta_query' => array(
array(
'key' => '_stock_status',
'value' => 'instock'
)
)
) );
if ( $liquor->have_posts() ) : while ( $liquor->have_posts() ) : $liquor->the_post();
?>
<?php
$liquor_brands = get_terms('pa_liquor-brands');
foreach ( $liquor_brands as $liquor_brand ) :
?>
<?php endforeach; ?>
<div id="post-<?php the_ID(); ?>" class="three columns product-post">
<?php echo $liquor_brand->slug ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endwhile; else: ?>
<?php //error message ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
Here is the screenshot of the output. It only shows the last value that I have set, which is "very-old-captain-rum":