S
S
SEOInquisitor2021-12-22 19:30:09
WordPress
SEOInquisitor, 2021-12-22 19:30:09

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 61c3521f54f84685059984.png

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 61c3524655385870399441.png

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

1 answer(s)
M
Maxim, 2021-12-29
@GMD

The easiest way to add
pointer-events: none;
in css for the list of taxonomies at the specified location.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question