- This topic has 8 replies, 3 voices, and was last updated 7 years, 9 months ago by Owen.
-
AuthorPosts
-
August 13, 2015 at 10:53 pm #129159Caroline
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 );
August 13, 2015 at 11:23 pm #129187TomLead DeveloperLead DeveloperThey 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).
August 13, 2015 at 11:31 pm #129188CarolineIt´s not woocommerce support I asked, but KIA Subtitle support forum.
August 13, 2015 at 11:58 pm #129192TomLead DeveloperLead DeveloperGotcha. 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 🙂
August 14, 2015 at 12:00 am #129194CarolineI 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
August 14, 2015 at 12:19 am #129195CarolineI want the subtitle to be H3 in the single product page but not on the category page. Do you know how I do this?
August 14, 2015 at 1:41 am #129200CarolineI got it the way I wanted with CSS so you dont have to answer on my last post.
August 14, 2015 at 9:06 am #129347TomLead DeveloperLead DeveloperAwesome – glad you got it all figured out! 🙂
June 9, 2016 at 4:15 pm #200616OwenHi 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 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.