My Problem is very strange – I don’t fully understand all the aspects of woocommerce just yet and am still fiddling with things to understand it.
I’m trying to pull in the size attributes for each product – I’m succeeding in pulling in the attributes but I’m pulling in all of them for every product. Not the one’s I’m adding to the product via the custom field.
Example of the attributes that should be pulled in
link
But I’m pulling all 6 of my created attributes not the one’s selected for each product.
link
The code I’m using to pull in the attributes is the following
<?php
$terms = get_terms('pa_size');
foreach ( $terms as $term ) {
echo "<li>" .$term->name. "</li>";
}
?>
You are confusing
get_terms()
withget_the_terms()
get_terms()
returns an array all the terms in a taxonomy.get_the_terms()
returns an array of all the terms for a particular post.You might also like
get_the_term_list()
which would be like so: