Skip to content

Instantly share code, notes, and snippets.

@DxDiagDx
Last active April 2, 2021 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DxDiagDx/3219bfb1c5ecb9745fa82c291199c168 to your computer and use it in GitHub Desktop.
Save DxDiagDx/3219bfb1c5ecb9745fa82c291199c168 to your computer and use it in GitHub Desktop.
Woo: убираем не нужный / лишний тег H2 на страницах категорий
// Заменяем тег <H2> на <H3> у подкатегорий
remove_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_category_title', 10 );
add_action( 'woocommerce_shop_loop_subcategory_title', 'custom_woocommerce_template_loop_category_title', 10 );
function custom_woocommerce_template_loop_category_title( $category ) {
echo '<h3 class="woocommerce-loop-category__title">';
echo esc_html( $category->name );
if ( $category->count > 0 ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo apply_filters( 'woocommerce_subcategory_count_html', ' <mark class="count">(' . esc_html( $category->count ) . ')</mark>', $category );
}
echo '</h3>';
}
// Заменяем тег <H2> на <p> у товаров
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
add_action( 'woocommerce_shop_loop_item_title', 'custom_woocommerce_template_loop_product_title', 10 );
function custom_woocommerce_template_loop_product_title() {
echo '<p class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment