Site logo

Archived topic

Set titles of posts to p

3 replies · Started by Vijay on July 24, 2022

Viewing posts 1–4 of 4

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?

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 ?

Thanks David, that did the trick

Glad to hear that!

This archived topic is closed to new replies.