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.

2 Answers 2

2

I had same problem and the solution is this

function mytheme_add_woocommerce_support() {
    add_theme_support( 'woocommerce' );
}

add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
1

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.

4
  • This is what I thought, but it is using the page template. This suggests that it isn't an archive page at all. Commented Nov 8, 2018 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
    Commented Nov 8, 2018 at 11:41
  • body classes: woocommerce woocommerce-page woocommerce-js Commented Nov 8, 2018 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
    Commented Nov 8, 2018 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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