L
L
lorab2022-03-10 19:15:15
WordPress
lorab, 2022-03-10 19:15:15

How to display in php not just a value, but a link to the attribute archive?

There is a code and it displays the name of the attribute under the price. But is it possible to display not only the text, but a link to the attribute's archive page?

add_action( 'woocommerce_after_shop_loop_item_title', 'custom_display_post_meta', 20 );
function custom_display_post_meta() {
   global $product;
   $attr = array('pa_kollekcziya'); 
   foreach ( $attr as $key=>$attribute ) {
   $values = wc_get_product_terms( $product->id, $attribute, array( 'fields' => 'names' ) );
   if (!empty($values))
    echo '<div><span>'. implode( $values ).'</span></div>';
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question