Changes to archive-product.php do not work

I am trying to set up a standard woocommerce theme and it still worked fine. I copied all the template files from /plugins/woocommerce/templates to /mytheme/woocommerce and configured the files.

But when I change something in archive-product.php , nothing happens? I even tried /plugins/woocommerce/templates/archive-product.php this up in the main files ( /plugins/woocommerce/templates/archive-product.php ), but I am not working.

I want to change the header class h1 : <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> .

So, I searched for all the woocommerce template files, the page-title class is found only in this single file (to prevent editing the wrong file).

Edit:

In detail, I want to customize the theme used in this way: http://example.com/product-category/mycategory

+11
source share
5 answers

This seems to be a SOLLL issue in Woocommerce. For those who landed here, for me, starting with version 2.1.6, the following solution worked.

Obviously, the problem is that the woocommerce_content () function displays an invalid page for the contents of the archive.

I used the following to get around this:

replace woocommerce_content () in woocommerce.php with:

 if ( is_singular( 'product' ) ) { woocommerce_content(); }else{ //For ANY product archive. //Product taxonomy, product search or /shop landing woocommerce_get_template( 'archive-product.php' ); } 

Credit: solution found here

+12
source

Here is how I fixed mine:

  • Delete woocommerce.php in the theme folder.
  • Copy the TEMPLATE folder to the woocommerce plugin directory, paste it into your THEME folder and rename it to woocommerce.
  • Open the folder you just renamed, go to the store folder and edit wrapper-start.php and wrapper-end.php.
+7
source

If you use the woocommerce.php method, you cannot configure the product archive. You must use the hooks method

http://docs.woothemes.com/document/third-party-custom-theme-compatibility/ Please note: when creating woocommerce.php in the themes folder, you won’t be able to override the custom woocommerce / archive-product.php template because woocommerce. php takes precedence over archive-product.php. This is intended to prevent display problems.

+3
source

I tried all of the above solutions, but to no avail. No matter what I did, the archive-product.php was not used at all. Instead, most woocommerce pages used page.php from my theme.

The solution for me was to add support for the theme ... Which, it’s been a while since I used woocommerce, so I completely forgot about it. But after adding the following line to my functions.php file, the archive-product.php file (/mytheme/woocommerce/archive-product.php) is currently being used, and I can update it as I should.

 add_theme_support('woocommerce'); 
+2
source

you need to edit the file "taxonomy-product_cat.php" and add the conditional is_product_category ('mycategory').

  • open the theme folder and add a new subfolder named "woocommerce" to it.
  • copy the files "archive-product.php" and "taxonomy-product_cat.php" from / plugins / woocommerce / templates into the woocommerce subfolder in your theme.
  • rename "archive-product.php" to "archive-mycategory.php" (or whatever you like, it will be a template file in the category).
  • open "taxonomy-product_cat.php" and wrap wc_get_template( 'archive-product.php' ); via

     if (is_product_category( 'mycategory' )){ wc_get_template( 'archive-mycategory.php' ); 

    } else {wc_get_template ('archive-product.php'); }

+1
source

Source: https://habr.com/ru/post/1500360/


All Articles