Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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
    Mauro

    #1448867

    Hey 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,
    Ismael

    #1448900

    Hello Ismael,
    thank you. It works.
    Having two H1 is a mistake. Will be fixed in a future update?
    Best regards,
    Mauro

    #1448959

    Hi,

    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,
    Ismael

    #1449594

    Hello 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,
    Mauro

    #1450039

    Hi,

    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,
    Ismael

    #1450571

    Ok, i understand, thank you

    Please note that, also in this page, there are two closing </header> tags and no opening <header>

    Best regards,
    Mauro

    #1450611

    Hi,
    When I check the two pages that you linked to I see two opening and closing header tags:
    Enfold Support 6093
    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,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.