• Resolved fermanus

    (@fermanus)


    Hello,

    Using OceanWP the default tag for product titles in woocommerce shop page appears to be just “a href…”. Is it possibly to simply wrap “the title” with h2 tags. I can do this by modifying the line echoing “get_the_title” in owp-product-archive.php and it is also possible (but not easy) from functions.php but I find both methods a bit awkward. Is there a more straightforward way to add tags to the product title in shop page (not js or jQuery)?

    Thanks

    • This topic was modified 4 years, 2 months ago by fermanus.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Please try to add the below code in the functions.php file of your child theme

    if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
    	remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
    }
    add_action( 'woocommerce_shop_loop_item_title', 'owp_template_loop_product_title', 10 );
    function owp_template_loop_product_title() {
    	echo '<h2 class="woocommerce-loop-product_title"><a href="'.get_the_permalink().'">' . get_the_title() . '</a></h2>';
    }
    
    Thread Starter fermanus

    (@fermanus)

    Hi,
    Thank you very much for your answer. I tried it and it works fine except for the “remove_action” part which does not remove the default title. I have to use some finely adjusted “display-none” CSS which is no problem.
    Alternatively, the method in which I copy/modify the owp-archive-product file in the OceanWP child theme also works well (without the need to add additional CSS).

    Wouldn’t it be useful if the product titles were wrapped in “h2” tags instead of simply “a” as this is the normal formatting in woocommerce?

    Thanks a lot again for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add h2 tag to woocommerce product title’ is closed to new replies.