Reputation: 41
I'm having a problem with WooCommerce / Wordpress templates. I used to have everything working.
I have this code in my functions.php
file:
add_filter( 'template_include', 'wpse138858_woocommerce_category_archive_template' );
function wpse138858_woocommerce_category_archive_template( $original_template ) {
if ( is_product_category() ) {
return get_template_directory().'/woocommerce/archive-product.php';
} else {
return $original_template;
}
}
This code chose my custom archive template for product categories and shop the main page. Suddenly, it's not working anymore. It seems like WordPress cannot use custom files from wp-content/themes/mytheme/woocommerce
anymore. Single product page and product categories use page.php
for some reason. I fixed an issue with single product page by creating file single-product.php on my theme folder. This works okay but I can't do the same with Woocommerce archive pages.
All archive pages uses page.php. They don't have pageId and I print out var_dump(is_product_category());
on some product category page, result is false.
Is there any way to force product categories to use archive-product.php
template? How is it possible that category (archive) page uses page.php
template?
Upvotes: 4
Views: 3392
Reputation: 131
Add add_theme_support( 'woocommerce' );
in your theme functions.php
file. After this all WooCommerce templates will work as expected ( provided that the structure of the templates is correct ).
Upvotes: 3