C
C
Comer2022-01-08 01:13:06
WordPress
Comer, 2022-01-08 01:13:06

How to set h1 title for Woocommerce product categories?

Good afternoon. There was a need to fix the heading h1 of product categories. the default is h3. There is a function:
if(strpos($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], '/product-category/'))
add_filter ( 'woocommerce_show_page_title' , 'mayak_woocommerce_product_cat_h1' ​​, 10 , 2 );
function mayak_product_cat_h1(){
$pch = get_term_meta (get_queried_object()->term_id, 'h1', true);
echo ''.$pch.'';
if(empty($pch)){
echo ''.get_queried_object()->name.'';
}
}
function mayak_woocommerce_product_cat_h1(){
return mayak_product_cat_h1($pch);
}
Everything works, h1 is set, but breadcrumbs fly off and in general the name of the category takes on a standard form, different from the topic. Tell me what to add so that h1 remains and the category name looks right.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lexchz, 2022-01-08
@lexchz

And what prevents the template from changing h3 to h1?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question