-
AuthorPosts
-
June 10, 2024 at 3:38 pm #1448784
Hello,
in product category pages and in tag pages there are two H1 tag,
one I have hidden it with display:none, but still is marked as a major mistake by search engines
How can I remove the second programmatically?
I am already using this code https://kriesi.at/support/topic/how-to-customize-blog-category-page-layout/#post-1297910
to remove the prefix from the category title.
Thank you
MauroJune 11, 2024 at 5:46 am #1448867Hey profumopuntoit,
Thank you for the inquiry.
You can add this filter in the functions.php file to disable or remove the default category title:
add_filter('woocommerce_show_page_title', 'av_woocommerce_show_page_title_mod'); function av_woocommerce_show_page_title_mod() { if (is_product_category()) { return false; } return true; }
Best regards,
IsmaelJune 11, 2024 at 2:48 pm #1448900Hello Ismael,
thank you. It works.
Having two H1 is a mistake. Will be fixed in a future update?
Best regards,
MauroJune 12, 2024 at 6:37 am #1448959Hi,
Thank you for the update.
You can disable the default title by adjusting the Header Title and Breadcrumbs settings in the Enfold > Header > Header Layout tab. This should also remove the duplicate h1 tag on the product category pages.
Best regards,
IsmaelJune 13, 2024 at 6:22 pm #1449594Hello Ismael,
for us, is OK to have the H1 as up as possible in the code, that means leaving Header Title and Breadcrumbs enabled. The problem for us is that we want to have a granular control and display a custom handwritten title. For this reason we have disabled, with display:none; the second H1, and we handwrite a H2 text
In any case, if someone, for whatever reason, chooses like us to leave Header Title and Breadcrumbs enabled, it is a mistake to output two H1 tags in the code. The second one should be H2
Best regards,
MauroJune 14, 2024 at 2:36 am #1450039Hi,
Thank you for the update.
The second heading tag in the product category pages is directly generated from a WooCommerce template. If you need to replace the h1 tag with h2, you have to override the plugins/woocommerce/templates/archive-product.php file, or keep the filter that we previously suggested to prevent the second h1 from rendering.
The heading tag is located around line 33 of the archive-product.php file:
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?> <h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1> <?php endif; ?>
Best regards,
IsmaelJune 14, 2024 at 5:00 pm #1450571Ok, i understand, thank you
Please note that, also in this page, there are two closing </header> tags and no opening <header>
Best regards,
MauroJune 15, 2024 at 2:42 pm #1450611Hi,
When I check the two pages that you linked to I see two opening and closing header tags:
one set is around the theme header, and the othr set is around the woocommerce page template title, since both are closed this should not cause any issues.
But if you want to change the woocommerce header tag to a div, add this code to the end of your child theme functions.php file in Appearance ▸ Editor:function change_woo_header_tag_to_div() { ?> <script> (function($) { $(function() { function replaceElementTag(targetSelector, newTagString) { $(targetSelector).each(function(){ var newElem = $(newTagString, {html: $(this).html()}); $.each(this.attributes, function() { newElem.attr(this.name, this.value); }); $(this).replaceWith(newElem); }); } replaceElementTag('header.woocommerce-products-header', '<div></div>'); }); }(jQuery)); </script> <?php } add_action( 'wp_footer', 'change_woo_header_tag_to_div', 99 );
Best regards,
MikeJune 26, 2024 at 4:32 pm #1459622Thank you Mike
June 27, 2024 at 4:11 am #1459802Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Double H1 tag in product categories pages and tag pages’ is closed to new replies.