[Resolved] Set titles of posts to p

Home Forums Support [Resolved] Set titles of posts to p

Home Forums Support Set titles of posts to p

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2291786
    Vijay

    When I visit a WooCommerce Product Tag archive page, each of the 100 posts tagged ‘Chrysler building’ have a H2 (with a class .woocommerce-loop-product__title)

    Is there some code I can add to display these as P or DIV rather than as H2s?
    or can I configure this via Customizer?

    #2291869
    David
    Staff
    Customer Support

    Hi there,

    the Theme doesn’t interfere with the Woocommerce templates, and that element tag is hardcoded in the woo function – see here:

    https://github.com/woocommerce/woocommerce/blob/6627fdb5ed52e907b17a3846d1127c9a646a9236/plugins/woocommerce/includes/wc-template-functions.php#L1165

    You can simply overwrite that function like so by adding your own copy in your child theme functions.php eg.

    function woocommerce_template_loop_product_title() {
        echo '<div class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    }

    But do you want this only on that specific archive page ?

    #2296822
    Vijay

    Thanks David, that did the trick

    #2297089
    David
    Staff
    Customer Support

    Glad to hear that!

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