Display WooCommerce category description and custom category titles

WooCommerce category description and custom title

David Nash woocommerce, wordpress 4 Comments

The WooCommerce category description is a good way to increase usability and improve SEO on your site. We can also show a custom category title which is a little more descriptive.

To do this, it’s good practise to start with something easy, get that working, and then build from there.

Show the WooCommerce category description

In the child theme, if it doesn’t already exist, create a woocommerce/ directory. Copy the template file from wp-content/plugins/woocommerce/templates/archive-product.php  to wp-content/themes/[your-child-theme]/woocommerce/archive-product.php. Now we can edit that without changing any plugin files directly (which could get replaced on the next update).

In WooCommerce 2.0.0+, towards the top of the file you should see this:

Below that code, add the following:

In wp-admin, go to Products > Categories and edit a category to make sure there is a description to display.

Save the archive-product.php file above and view your category. You should now see the description.

Display a custom title for WooCommerce product category pages

To do this we’ll use the excellent Advanced Custom Fields plugin. Install it if you haven’t already. Create a field group called “Product category title”. Add a field and call it “Category title”. The default is text, leave it as is.

Under “Location” change the rule to show this field group if Taxonomy Term is equal to product_cat and publish the field group:

Create a custom category title for WooCommerce

ACF field group display rule

In wp-admin, go back to Products > Category > [edit your category]. Now when you scroll down you should see your field. Enter your custom category name.

Then in your archive-product.php file, update the code you entered earlier to match this:

You might also need to comment out the existing <h1 class="page-title">   in that file, so you don’t end up with two titles.

That’s it! Just a few lines of code means you can now show your WooCommerce category description and a custom title.

Comments 4

  1. Hi David, I know this is a slightly older thread but I found it and is helpful to what I’m trying to do…

    Is there a way to modify the add ‘show category description’ so it only appears on the category pages and NOT the main shop page? I’m having a problem because there is a default description on the main shop page that says “This is where you can add new products to your store.” and I can’t figure out where that is coming from. I either need to take the description off of that page, or identify where the description is coming from so I can re-word it.

    Here is the staging site that I’m working on where you will see what I am dealing with –

    Your help is much appreciated!

Leave a Reply

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