0

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

0

Usually 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.org/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.

  • I've already made a child of the paid theme, i've tweaked different things for now like the style of the products list when you are in a specific category (instead of little box i made wider rectangle) but for the search result page its different. The paid theme doesnt have a search.php file, it contains searform.php where you can customize the search form but not the result page. (note that even if the theme doesnt have a search.php file it still been designed like other product category page) My apologize for my english i've some difficulties to explain my problems clearly – JiyoV Jul 5 at 19:21
  • @JiyoV If the parent theme is missing an search.php then it most likely uses the index.php file. You can override it within your child theme ( just copy the parent's index file there ). If you would like tweak something within in only for the search results do a conditional check is_search(). The other thing is to create a search.php of your own. :) Take a look at this developer.wordpress.org/themes/basics/template-hierarchy/… – Kuliraj Jul 6 at 20:36
0

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

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.