Display WooCommerce Product Category Description on All Category Pages

WooCommerce Logo

Posted on November 25, 2015 in Development, Web

Out of the box, WooCommerce displays the product category description only on the first page of the category archive. In other words, if the category contains a bunch of products and is paginated, the category description will not be shown on page 2, 3, etc.

But what if you want to display the category description on all the paginated pages? What if, for example, you are running a special promotion and want to include the promotion details in the category description and make sure your shop visitor sees it regardless of which page of the category s/he is on?

The solution is quite straight-forward. Add the following code to your theme’s functions.php file:

The WooCommerce category pages’ layout is governed by the /templates/archive-product.php template and we leverage the woocommerce_archive_description action hook called in this template.

Our custom function above is almost a carbon copy of the default woocommerce_taxonomy_archive_description function, with only one difference: instead of using get_query_var( 'paged' ) == 0 as in the default function, we use get_query_var( 'paged' ) != 0.

This ensures that the category description is added on all the category pages. Since we do not override the default function, but merely hook into the woocommerce_archive_description action, the category description is still added on the first category page by the default function.

Enjoyed this post? Share it with others.
Email this to someoneShare on FacebookShare on Google+Tweet about this on Twitter

Responses (31)

  1. Name (required)Vali
    March 11, 2016 at 1:25 am · Reply

    Nicely done

    • pixel.ninja
      March 11, 2016 at 1:48 am ·

      Thanks, Vali, appreciated!

  2. Umberto
    May 3, 2016 at 8:16 pm · Reply

    thank you!

  3. subrat
    May 14, 2016 at 1:51 pm · Reply


    I am facing the same issue in shop page where shop description is showing in main page but not on paginations.

    Any clues what to do here.

    • pixel.ninja
      May 14, 2016 at 2:48 pm ·

      Hi Subrat,

      I’m not entirely sure what you mean by “shop page” and “shop description”; could you please clarify? The blog post is about the product category description and the category pages.

  4. Ashley
    May 20, 2016 at 5:14 am · Reply

    Perfect! Thank you! Love your website!

    • pixel.ninja
      May 20, 2016 at 12:33 pm ·

      Thank you very much for your kind words, Ashley, much appreciated!

  5. Ryan
    September 17, 2016 at 11:59 pm · Reply

    Thank you!!!

    • pixel.ninja
      September 18, 2016 at 1:15 am ·

      You’re most welcome!

  6. Manvendra
    October 8, 2016 at 5:05 am · Reply

    This is not working for me. website: http://www.shoppingandcoupon.com/

  7. […] Crédito: Pixel Ninja […]

  8. Wayne
    March 22, 2017 at 7:59 pm · Reply

    Hi, this works great and does indeed display on every paginated page, but I was wondering if you were able to help.

    I added the following to my functions.php:

    remove_action( ‘woocommerce_archive_description’, ‘woocommerce_taxonomy_archive_description’, 10 );

    add_action( ‘woocommerce_after_shop_loop’, ‘woocommerce_taxonomy_archive_description’, 100 );

    to get the category description to display at the bottom, which works fine, but when I add your code above, the first page works as normal with description underneath the products, but the description appears above th products again on the second and following pages.

    Is there any way of combining the above and your code to allow every page to display the description to the bottom?

    Thanks in advance, p.s. as you can probably tell I’m not a hard-core coder 🙂

    • pixel.ninja
      March 22, 2017 at 9:54 pm ·

      Hi Wayne,

      Thanks for stopping by. I’m glad that you found the snippet useful.

      Regarding your question, try this:

      Notice that I removed the get_query_var( 'paged' ) != 0 condition from the if statement in the original version of the custom function. Since we want to display the category description on all pages (including the first one), we don’t need to check which page we’re on.

      I didn’t test this, but I think it should sort you out. Let me know how it goes.

  9. baudouin
    March 28, 2017 at 9:13 pm · Reply

    Hey Mr Ninja. I am trying to display a category description when using the woocommerce element “Product categories” (Display product categories loop)
    It displays by default the image, the name and the number of product inside that category. But not the description.

    I can’t find the action to hook the function with

    • pixel.ninja
      March 28, 2017 at 10:10 pm ·

      Hi Baudouin,

      It’s a little bit difficult for me to give you an exact answer for this as I would need to see your code and learn more about the context you’re trying to display the category description in. That being said, the WooCommerce product categories are just a regular WordPress custom taxonomy, so you can use the WordPress get_term() or get_terms() functions to retrieve the term data from the database (including the description). So something along these lines:

      See more here, for example.

      I hope this helps to point you in the right direction.

  10. baudouin
    March 29, 2017 at 2:45 am · Reply

    Hey Mr Ninja,

    Sorry I didn’t provide enough context. I am developing a website using wordpress with a theme named porto. Woocommerce comes as a plugin. I have as well a plugin named Visual composer. So when I created a new page (I do not like the default pages created by the theme and the way woocommerce pushes you to link the shop to a certain page) I added one of those “element” that you can find in the visual composer under the woocommerce category.
    To do so, I created a row container, a custom column. Inside that column I added this Product category loops, and chose to display only 1 category. The theme give you the option (appearance) to display the thumb image, the name and the quantity of the product under that category. What I wanted was to display the description next to the thumb image.

    What you gave me helped me understand where to look at!

    What I did, I edited the content-product_cat.php (~/woocommerce/) and added the element from the class with $category->description.

    But I think it’s not really convenient the change the code that way. So I wanted to find the action to hook my custom function with. And add the code in function.php

    Anyway, it works now so I won’t complain.
    I have been looking at your website and you profile, it is really great. The page looks fantastic, you story is source of inspiration! Plus you are helping people on your blog, with fast answer. You really are the ninja that internet deserve 🙂

    Take care!

    • pixel.ninja
      March 29, 2017 at 11:53 am ·

      Thank you for your kind words, much appreciated. It’s always heartwarming when somebody finds the blog useful.

      Regarding your issue, I’m glad you figured it out. I don’t think the ‘WooCommerce Category’ is one of the default Visual Composer’s elements, so it must have been added by the theme. Hence the best way to change the output will depend on how the theme added the element in the first place. Overriding the element’s definition file in your child theme is a completely viable way. From what you wrote it sounds like that’s what you did (I hope you’re using a child theme and didn’t modify the file directly in the parent theme itself!). But you could also probably remove the added element and add it again using the Visual Composer API in your functions.php. Or create a brand new element that would do exactly what you want. As it’s often the case with WordPress, there are multiple ways to achieve the same result 🙂

  11. baudouin
    March 29, 2017 at 9:34 pm · Reply

    You are very Welcome.

    Awesome, I didn’t think about creating my own vp element!

    About the parent/child I am not sure ;/ I went into appearance, editor and under theme to edit (porto in my case) I found my php files.
    So I am guessing that I actually edited the parent theme :/ Is that really bad? and why?

    • pixel.ninja
      March 29, 2017 at 10:27 pm ·

      If you’re making any customizations to your site, you almost always want to use a child theme. The main issue with not using one is that when you update the parent theme (when the original developer releases a new patch or update), your modifications may be overwritten by the update and ultimately lost. Using a child theme ensures that your modifications are preserved and makes the theme update process much more straightforward.

      There are other advantages as well and if you google around a little, you’ll find plenty of resources on child themes. This Smashing Magazine article is a good place to start.

      Popular commercial themes often come with an easy-to-install child theme skeleton, so it’s easy to get started. I’m not 100% certain, but I think Porto has one too (it’d be part of the theme bundle).

  12. Baudouin
    March 30, 2017 at 9:56 pm · Reply

    Ok I didn’t know that.
    I found the child theme, but I guess It’s a bit too late for my current website.

    Thank you so much again for your help!

  13. baudouin
    April 20, 2017 at 9:48 pm · Reply

    Hi Mr Ninja!
    Today is the day I have to create a child theme I think

    So Does that mean I’m gonna have to redo my entire website ? How can I do the transition to a child theme and then update the parent one ?

    • pixel.ninja
      April 21, 2017 at 2:26 am ·

      That really depends on the extent of modifications to the parent theme you made and how you made them. For example, if you edited some of the theme files directly, the migration to the child theme will be more involved than if you just configured the theme through the WordPress admin system. But overall you shouldn’t need to redo your entire site, only apply the same modifications and configuration to the child theme.

      There are plenty of good tutorials online on setting up and using WordPress child themes, so I would suggest that you look some up and go through them carefully before you start working on the migration process. Oftentimes commercial themes come with a skeleton child theme and some documentation on how to use it – perhaps yours does as well – so that might help you too.

      I’m sorry if this is a bit vague, but it’s a fairly wide topic, beyond the scope of a simple comment. Good luck!

  14. Pheel
    September 5, 2017 at 2:31 am · Reply

    Hi there, I’m using the Panoramic premium theme on my site and when I add the snippet, piece of code to the function.php nothing happens and no category or production description shows. Not sure why?

    • Richard
      September 5, 2017 at 11:23 am ·

      Hi Pheel,

      Hmm, that sounds strange. I’m not familiar with the Panoramic theme, but I had a quick look at the free version and I don’t see anything in the theme’s code that should conflict with the snippet.

      Two quick questions: (1) Before you added the snippet, did the category and product descriptions display fine? (2) When you insert the snippet and the category and product descriptions don’t show, does the rest of your site work ok?

  15. David F
    October 10, 2017 at 4:17 pm · Reply

    Works like a charm, thanks!

    • Richard
      October 10, 2017 at 4:25 pm ·

      Awesome, my pleasure!

  16. Martin
    December 10, 2017 at 7:26 am · Reply

    Worked great to get the cat. descriptions on each of my paginated category pages, thank you.

    • Richard
      December 10, 2017 at 11:44 am ·

      Fantastic, I’m glad to hear that. You’re most welcome.

  17. Mahendra
    February 5, 2018 at 1:45 am · Reply

    nice article

    • Richard
      February 5, 2018 at 9:39 pm ·

      Thank you, Mahendra, much appreciated.

Leave a reply

Your email address will not be published. Required fields are marked *