Site logo

Archived topic

Custom category description woocommerce_after_single_product

6 replies · Started by Ivan Cazorla on October 15, 2018

Viewing posts 1–7 of 7

Hi there,

I've figured out a way to add a second, larger description (after showing the products) in my woocommerce categories using this hook:

add_action( 'woocommerce_after_main_content', 'my_custom_text', 10 );
 
function my_custom_text() {
echo '<h1>My title here</h1><p>Description goes here.</p>';
}

I was wondering if I can make a custom different text for every category in my store, instead of having just one custom text for each one of them. Is that possible?

Let me know. Thanks!

So then I should put in my function the tag of my cateogry like so?

add_action( 'woocommerce_after_main_content', 'my_custom_text', 10 );
 
function my_custom_text() {
if ( is_product_category() ) {
  if ( is_product_category( 'shirts' ) ) {
    echo 'Hi! Take a look at our sweet tshirts below.';
  } else {
    echo 'Hi! Check our our products below.';
  }
}
}

Let's see if that would work!

Hi there, looks like its working! Nice! Thanks.

But know, do I really need to put all category descriptions inside this snippet hook, or is there an easy way to create a field on the woocommerce category to introduce that text? So that other people can easily modify the text they want to show?

thanks,

You'd have to ask WooCommerce for that.

You can see that's it's not controlled by GP by the link I provided.

Glad I could help!

Yep, I have asked them and I'll see if I manage to do what I want.

thanks!!

No problem :)

This archived topic is closed to new replies.