Home › Forums › WoodMart support forum › Add H2 to woocommerce-product-details__short-description
Add H2 to woocommerce-product-details__short-description
- This topic has 10 replies, 2 voices, and was last updated 1 month ago by
Luke Nielsen.
-
AuthorPosts
-
June 9, 2025 at 3:46 pm #666200
AndreiParticipantHi.
Is there a way to make the following changes to the single product page?
1. Add H2 to > woocommerce-product-details__short-description (currently no heading)
2. Add h3 to > related products(currently h2)p.s. i am already using the code bellow to change h3 > h2 on product archive page:
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); add_action( 'woocommerce_shop_loop_item_title', function() { echo '<h2 class="wd-entities-title"><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h2>'; }, 10 );
Thanks!
June 10, 2025 at 9:23 am #666326
Luke NielsenKeymasterHello,
1. Copy this
woocommerce/templates/single-product/short-description.php
file (with path) to the child theme and replace the tag there.2. Use Layouts to change the title – https://prnt.sc/XqCe2eS24cav
Kind Regards
June 10, 2025 at 8:14 pm #666590
AndreiParticipantHi.
I made that work, but the correct path was: woodmart-child/woocommerce/single-product/
Can you please help me change the product title from the Related Products carousel from h2 to h3?
Thank you for all the help.
Andrei
June 11, 2025 at 10:45 am #666659
Luke NielsenKeymasterHello,
Use the code below for help:
/** * Change related products title tag */ add_filter( 'woodmart_related_products_args', function( $args ) { $args['element_title_tag'] = 'h5'; // Change h5 to any tag you want (h1, h2, h3, h4, h5, h6, div, span, etc.) return $args; });
Kind Regards
-
This reply was modified 1 month ago by
Luke Nielsen.
June 11, 2025 at 11:45 am #666681
AndreiParticipantHi.
I added the above code but there is not change.
Attachments:
You must be logged in to view attached files.June 11, 2025 at 11:46 am #666683
AndreiParticipantI think the hook you provided changes the section title tag, but not the product loop title tag.
June 11, 2025 at 12:49 pm #666718
Luke NielsenKeymasterHello,
Yep, it was for the title of the section.
Either the issue in your code that you found – https://prnt.sc/Lr3rbvskeGaD or there are some mistakes in the file.
For example, here is the below custom to change the title in the Shop:
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) { function woocommerce_template_loop_product_title() { echo '<span class="wd-entities-title"><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></span>'; } }
And it changes the tag in the Shop – https://prnt.sc/Q6v-MEAY45Kf and in other places like Single product – https://prnt.sc/Zif8eo6oyQcH
Kind Regards
June 11, 2025 at 1:07 pm #666722
AndreiParticipantHi and thanks for the quick answer. Perhaps i was not explaining properly.
In the single product page i have at the end Related products carousel that loops related products. Each of these products has the title with <h2> tag. Ideally i would want to change that to <h3>, but only for related products in single product view. (if possible)
Thank you again for such prompt reply.
AndreiJune 11, 2025 at 4:00 pm #666803
Luke NielsenKeymasterTry to use the code below:
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) { function woocommerce_template_loop_product_title() { // Check if we're on a single product page and in the related products section if ( is_singular( 'product' ) && doing_action( 'woodmart_woocommerce_after_sidebar' ) ) { echo '<h3 class="wd-entities-title"><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h3>'; } else { echo '<h2 class="wd-entities-title"><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h2>'; } } }
Shop: https://prnt.sc/iXRp9_hbA-7v
Product page: https://prnt.sc/hQM_3L8nrQ25Kind Regards
June 11, 2025 at 7:37 pm #666849
AndreiParticipantHi again. this seems to be working ok now!
Thank you so much!June 12, 2025 at 10:12 am #666934
Luke NielsenKeymasterHello,
Thank you for confirming that the solution is working properly for you. We’re pleased to hear that the changes are successful now. If you have any further questions or needs, feel free to reach out again.
Kind regards
-
This reply was modified 1 month ago by
-
AuthorPosts
The topic ‘Add H2 to woocommerce-product-details__short-description’ is closed to new replies.
- You must be logged in to create new topics. Login / Register