Home Forums WoodMart support forum Add H2 to woocommerce-product-details__short-description

Add H2 to woocommerce-product-details__short-description

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #666200

    Andrei
    Participant

    Hi.

    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!

    #666326

    Luke Nielsen
    Keymaster

    Hello,

    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

    #666590

    Andrei
    Participant

    Hi.

    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

    #666659

    Luke Nielsen
    Keymaster

    Hello,

    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

    #666681

    Andrei
    Participant

    Hi.

    I added the above code but there is not change.

    Attachments:
    You must be logged in to view attached files.
    #666683

    Andrei
    Participant

    I think the hook you provided changes the section title tag, but not the product loop title tag.

    #666718

    Luke Nielsen
    Keymaster

    Hello,

    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

    #666722

    Andrei
    Participant

    Hi 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.
    Andrei

    #666803

    Luke Nielsen
    Keymaster

    Try 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_3L8nrQ25

    Kind Regards

    #666849

    Andrei
    Participant

    Hi again. this seems to be working ok now!
    Thank you so much!

    #666934

    Luke Nielsen
    Keymaster

    Hello,

    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

Tagged: ,

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Add H2 to woocommerce-product-details__short-description’ is closed to new replies.