admin管理员组

文章数量:1335598

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.

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.

Share Improve this question edited Nov 8, 2018 at 11:30 Krzysiek Dróżdż 25.5k9 gold badges53 silver badges74 bronze badges asked Nov 8, 2018 at 11:22 William OakleyWilliam Oakley 1111 silver badge6 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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' );

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.

本文标签: WooCommerce template page for category