Skip to content

Instantly share code, notes, and snippets.

@DxDiagDx
Last active Apr 2, 2021
Embed
What would you like to do?
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