How to display a custom attribute with the name of the product on the shop page in woocommerce?

There is a solution, but not complete.
Add the code in functions.php
my_template_loop_product_title function(){
 global $product;
 echo '<h3 itemprop="name" class="product_title entry-title">';
 $versionvalues = get_the_terms( $product->id, 'pa_model');

 foreach ( $versionvalues as $versionvalue ) {
 echo $versionvalue->name;
}
 echo '</h3>';
}
add_action( 'woocommerce_shop_loop_item_title', 'my_template_loop_product_title', 10 );


But this code must be inserted in the place where should be displayed the attribute:
<?php

$subheadingvalues = get_the_terms( $product->id, 'pa_model');

if ($subheadingvalues): ?>
<b>Name:<b>
 <?php foreach ( $subheadingvalues as $subheadingvalue ): ?>
 <?php echo $subheadingvalue->name; ?>
 <?php endforeach; ?>
<?php endif; ?>


Just where is this place?

The source code of woocommerce (archive-product.php, content-product.php ) output is produced via do_action( 'woocommerce_before_shop_loop_item_title' ); and between them to insert the needed code is not clear.
March 12th 20 at 08:39
1 answer
March 12th 20 at 08:41
Solution
But this code must be inserted in the place where should be displayed the attribute:

so it is already inserted You in "my_template_loop_product_title".
Any files that are not necessary to climb. You connect to the desired piece of code through the hook that You have made above.

But here visually see what a hook. Helps me
Thank you, my good man! It turns out the second is just a variation of the code from function.php from right?
Complete and working code should look like this:

my_template_loop_product_title function(){
 global $product;
 echo '<span itemprop="name" class="product_title entry-title">';
 $subheadingvalues = get_the_terms( $product->id, 'pa_avtory');

 if ($subheadingvalues){
 echo '<b>Authors:<b><br>';
 foreach ($subheadingvalues as $subheadingvalue) {
 echo $subheadingvalue->name.'<br>';
}
}
 echo '</span>';
}
add_action( 'woocommerce_shop_loop_item_title', 'my_template_loop_product_title', 10 );
- Opal.Hans commented on March 12th 20 at 08:44
Well, Yes.
Another point:
if $subheadingvalues is empty, You will draw the extra tag <span..... Really that need?
And if is not empty, then at the end of the list of authors would be superfluous tag <br>or he is also needed? - thurman_Sawayn commented on March 12th 20 at 08:47

Find more questions by tags WooCommerce