Changes on archive-product.php doesn't work

前端 未结 6 585
栀梦
栀梦 2021-01-04 01:49

I\'m trying to customize the standard woocommerce theme and so far that has worked well. I copied all template files from /plugins/woocommerce/templates to

相关标签:
6条回答
  • 2021-01-04 01:59

    Here's how I fixed mine:

    1. Delete woocommerce.php in your theme folder.
    2. Copy TEMPLATE folder in woocommerce plugin dir, paste it in your THEME folder, and rename it to woocommerce.
    3. Open the folder you just renamed, go to shop folder, and edit wrapper-start.php and wrapper-end.php.
    0 讨论(0)
  • 2021-01-04 02:11

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

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

    add_theme_support('woocommerce');
    
    0 讨论(0)
  • 2021-01-04 02:14

    Seems this is STILL an issue in Woocommerce. For anyone landing here, the following solution was working for me as of version 2.1.6.

    Apparently the problem is due to the function woocommerce_content() outputting the wrong page for archive content.

    I used the following to get around it:

    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: found the solution here

    0 讨论(0)
  • 2021-01-04 02:17

    For others searching here, doublecheck the path. It is for example not /mytheme/woocommerce/templates/archive-product.php but only /mytheme/woocommerce/archive-product.php. I didn't have to apply @Talk nerdy to me's patch or any other to make it work.

    0 讨论(0)
  • 2021-01-04 02:18

    If you use the woocommerce.php method you cannot customize archive-product. You must use the hooks method

    http://docs.woothemes.com/document/third-party-custom-theme-compatibility/ Please note: when creating woocommerce.php in your theme’s folder, you won’t be able to override the woocommerce/archive-product.php custom template as woocommerce.php has the priority over archive-product.php. This is intended to prevent display issues.

    0 讨论(0)
  • 2021-01-04 02:18

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

    1. open your theme folder and add a new subfolder named "woocommerce" to it.
    2. copy the files "archive-product.php" and "taxonomy-product_cat.php" from /plugins/woocommerce/templates to the woocommerce subfolder in your theme.
    3. rename "archive-product.php" to "archive-mycategory.php" (or whatever you like, this will be the template file to the category).
    4. open "taxonomy-product_cat.php" and wrap the wc_get_template( 'archive-product.php' ); with:
        if (is_product_category( 'mycategory' )){
            wc_get_template( 'archive-mycategory.php' );
        }  else {
            wc_get_template( 'archive-product.php' );
        }
    
    0 讨论(0)
提交回复
热议问题