1

How do I change the WordPress template used for the WooCommerce category pages?

I can change the product pages by using the single-product.php template, but the category pages just use page.php which I don't want to modify because it is so sidely used.

How do I modify this template and only affect category pages? I am NOT interested in overriding the WooCommerce templates, I want to edit the surrounding template that contains the header, footer, etc.

0

WooCommerce categories are called product_cat. If you check the WP template hierarchy, you see that for (custom) taxonomy archives, taxonomy-$taxonomy.php works.

So in your case, creating a taxonomy-product_cat.php should work.

You can copy the content from taxonomy.php, archive.php or index.php and start your work from there.

  • This is what I thought, but it is using the page template. This suggests that it isn't an archive page at all. – William Oakley Nov 8 '18 at 11:37
  • @WilliamOakley Please check my update, I mixed up category (which is a specific taxonomy) and taxonomies in general. With this it worked on my local install with WooCommerce. If it doesn't, can you post the HTML classes <body> has? – kero Nov 8 '18 at 11:41
  • body classes: woocommerce woocommerce-page woocommerce-js – William Oakley Nov 8 '18 at 13:20
  • No archive in there? Then it really is not the page for the category, but just a regular page (that may retrieve posts via shortcode, custom theme functionality). You can use page-$slug.php or page-$id.php then for this specific page – kero Nov 8 '18 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.