Answer the question
In order to leave comments, you need to log in
How to remove links from product attributes displayed in WooCommerce catalog?
Good day, I ran into a problem, please help me solve
The situation is as follows:
I want to display product attributes in the site catalog, I did it
But I want to remove taxonomy links, while leaving the font color blue, I can’t do it, or at least do it like this so that the taxonomy links lead to the product card from which they were taken I
use the following code in functions.php (child theme of Porto Child)
function atrb_productShoes2() {
global $product;
global $post;
$attributes = $product->get_attributes();
if ( ! $attributes ) {
return;
}
foreach ( $attributes as $attribute ) {
// Получение таксаномии
$terms = wp_get_post_terms( $product->id, $attribute[ 'name' ], 'all' );
$taxonomy = $terms[ 0 ]->taxonomy;
// Получение объекта таксаномии
$taxonomy_object = get_taxonomy( $taxonomy );
// Получение меток атрибутов
$attribute_label = $taxonomy_object->labels->name;
$attribute_label = str_replace('Товар', '', $attribute_label);
// Отображение метки с кликабельным списком терминов
echo get_the_term_list( $post->ID, $attribute[ 'name' ] , '<div class="attributes" align="left">' . $attribute_label . ': ' , ', ', '</div>' );
}
}
// Хук для вывода после заголовка товаров в категории
add_action( 'woocommerce_after_shop_loop_item_title', 'atrb_productShoes2' );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question