I have made a 'archive-product-custom.php' file who is called in 'taxonomy-product-cat.php'.
I do this to easily change the layout of product when a user is looking on a specific category page (in the archive-product-custom i changed the wc_get_template_part to my "content-product-custom" file)
This is the only one and easiest method i found for doing what i want without broke the entire theme (content-product template is used everywhere.. related, cart, up-sells, cross-sells)
Is it possible to change the layout of the search result with the same above techniques?
Or maybe you have a better solution for me? All i want is a custom product layout on each category page and search result without changing the cross-sells, up-sells and related product layout
I have made a 'archive-product-custom.php' file who is called in 'taxonomy-product-cat.php'.
I do this to easily change the layout of product when a user is looking on a specific category page (in the archive-product-custom i changed the wc_get_template_part to my "content-product-custom" file)
This is the only one and easiest method i found for doing what i want without broke the entire theme (content-product template is used everywhere.. related, cart, up-sells, cross-sells)
Is it possible to change the layout of the search result with the same above techniques?
Or maybe you have a better solution for me? All i want is a custom product layout on each category page and search result without changing the cross-sells, up-sells and related product layout
Share Improve this question edited Jul 2, 2019 at 16:35 JiyoV asked Jul 2, 2019 at 14:50 JiyoVJiyoV 231 gold badge1 silver badge6 bronze badges2 Answers
Reset to default 0Usually there is a comment at the start of each WC template file, which basically says: This template can be overridden by copying it to yourtheme/woocommerce/wc-template-name.php.
. This is the correct and recommended way to override WooCommerce templates.
I think you should look into having a child theme for when there is a theme that already have those templates overridden, or even if it doesn't. See https://developer.wordpress/themes/advanced-topics/child-themes/ for reference.
What I said above is applicable for the search.php
as well. Of course it will depend very much on your theme setup.
If you provide more details on where and what you're trying to achieve, then I can be more specific.
Finnaly i've done this in my archive-product.php
if (is_search())
wc_get_template_part( 'content', 'product-custom' );
else
wc_get_template_part( 'content', 'product' );
I don't know if its the right way but it works. Thanks for your help @Kuliraj