O
O
otec462019-11-28 21:28:13
WooCommerce
otec46, 2019-11-28 21:28:13

How to replace h2 tags in product titles in Woocommerce with divs?

Good afternoon. I really need help.
In Woocommerce, product names are displayed wrapped in an h2 tag. How to correctly replace it with a div?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pychev Anatoly, 2019-11-28
@pton

I did this, only changed to H3, correct for yourself on div

/**
 * Переопределяем функцию, т.к. нет из нее фильтра, а тег h2 надо поменять на h3
 */
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {

  /**
   * Show the product title in the product loop. By default this is an H2.
   */
  function woocommerce_template_loop_product_title() {
    echo '<h3 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</h3>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  }
}

O
otec46, 2019-11-28
@otec46

Thank you. I saw this solution. Doubt his literacy. I was wondering if there are other ways. How to style this class?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question