[Resolved] show subtitle on product category page

Home Forums Support show subtitle on product category page

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #129159
    Caroline

    I´m using the plugin KIA Subtitle, and have got the subtitle to show on single product page and even in cart.
    But I would like the subtitle to show on my product category page as well.
    On my product category page I now see my thumbnail, product title, price and add to cart button.
    But I want it to be my thumbnail, product title, subtitle, price and add to cart button.
    I asked on the plugin support but she answered the she couldn’t help me customize my WooCommerce theme.

    I have added this code to a snippet to get it to show on single product page and in cart.

    function kia_add_subtitle_to_woocommerce(){
        if( function_exists( 'the_subtitle' ) ) the_subtitle( '<h3 class="subtitle">', '</h3>' );
    }
    add_action( 'woocommerce_single_product_summary', 'kia_add_subtitle_to_woocommerce', 7 ); 
    
    function kia_subtitle_for_woocommerce_products( $title, $product ){
    
    	if( function_exists( 'get_the_subtitle' ) && $subtitle = get_the_subtitle( $product->id ) ){
    		$title .= ' | ' . $subtitle;
    	}
    	return $title;
    }
    add_filter( 'woocommerce_product_title', 'kia_subtitle_for_woocommerce_products', 10, 2 );
    
    #129187
    Tom
    Lead Developer
    Lead Developer

    They couldn’t even provide the proper hook/filter that you can use on the WooCommerce forums? Basically, you would do the same as you have above, but hooked into the necessary hook that’s being used in the category template.

    See if they can at least let you know what those hooks are (which is well within the scope of support they should provide).

    #129188
    Caroline

    It´s not woocommerce support I asked, but KIA Subtitle support forum.

    #129192
    Tom
    Lead Developer
    Lead Developer

    Gotcha. You’ll want to figure out the hooks for the WooCommerce category pages.

    For example, you’re currently hooking into: woocommerce_single_product_summary.

    You’ll want to find something like: woocommerce_category_product_summary (probably not an actual hook).

    If you ask in their forums they should be able to let you know – then you can hook the same function into it 🙂

    #129194
    Caroline

    I didnt know what to look for but you helped me find it 🙂
    On this page you can find all woocommerce hooks.

    function kia_add_subtitle_to_woocommerce(){
        if( function_exists( 'the_subtitle' ) ) the_subtitle( '<h3 class="subtitle">', '</h3>' );
    }
    add_action( 'woocommerce_single_product_summary', 'kia_add_subtitle_to_woocommerce', 7 ); 
    
    add_action( 'woocommerce_after_shop_loop_item_title', 'kia_add_subtitle_to_woocommerce', 7 ); 
    
    function kia_subtitle_for_woocommerce_products( $title, $product ){
    
    	if( function_exists( 'get_the_subtitle' ) && $subtitle = get_the_subtitle( $product->id ) ){
    		$title .= ' | ' . $subtitle;
    	}
    	return $title;
    }
    add_filter( 'woocommerce_product_title', 'kia_subtitle_for_woocommerce_products', 10, 2 );
    

    Now I just have to style it the way I want

    #129195
    Caroline

    I want the subtitle to be H3 in the single product page but not on the category page. Do you know how I do this?

    #129200
    Caroline

    I got it the way I wanted with CSS so you dont have to answer on my last post.

    #129347
    Tom
    Lead Developer
    Lead Developer

    Awesome – glad you got it all figured out! 🙂

    #200616
    Owen

    Hi Caroline, im looking to do this for my site where a subtitle (specifically going to be a price) is displayed beneath the category title. Im not 100% on the code above but am i right in assuming the code you posted wasnt changed to reflect the hooks for categories?

    I could probably fudge my way through that with the list but my brain hurts when i think where are these subtitles coming from, where are they specified for each category??

    Trying to understand the code as i go really. do you by any chance have the code you used?

    Heres hoping i can get this right as it would be fantastic to have 🙂

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