使用Underscores.me主题时WooCommerce archive-product.php覆盖失效问题
Hey there, let's tackle this WooCommerce template override issue you're facing with the Underscores.me theme. It's super frustrating when something that worked reliably suddenly breaks after an update, so let's break down the most likely fixes step by step:
First, let's recap your setup to make sure we're aligned:
- You’ve copied
plugins/woocommerce/templates/archive-product.phptomy-themes/woocommerce/archive-product.phpto override the core template - This worked perfectly before, but now fails only on the Underscores.me theme post-update
- Environment details: WC 3.3.5, Apache 2.4.18 (Ubuntu), PHP 5.6.33
1. Double-Check File Path & Child Theme Usage
Underscores (aka _s) follows WordPress template hierarchy strictly, and if you’re using the parent theme directly, any Underscores update would overwrite your custom woocommerce folder. Confirm:
- You’re using a child theme (always the best practice for Underscores!) and the override file lives at
wp-content/themes/your-underscores-child/woocommerce/archive-product.php - There are no typos in folder/filenames—Linux servers (like your Ubuntu setup) are case-sensitive, so
woocommercemust be all lowercase, andarchive-product.phpcan’t have any capitalization errors.
2. Verify Template Version Compatibility
WooCommerce 3.3.5 might have updated the core archive-product.php structure. Compare your theme’s override file to the core version:
- Look at the top comment block—WooCommerce adds a version tag like
* @version 3.3.0 - If your theme’s file has an older version, it might be incompatible with WC 3.3.5’s core logic, causing WooCommerce to fall back to the core template. Update your override file to match the core template’s base structure, then reapply your customizations.
3. Check for Theme Hooks/Filters Interfering
Underscores includes default hooks that could be overriding WooCommerce’s template loader. Head to your theme’s functions.php and look for:
- Filters using
template_includeorwoocommerce_template_loader - Any code that forces WooCommerce to use core templates
You can test this temporarily by renaming functions.php to functions-old.php (make a backup first!)—if the override starts working, you know a hook/filter in there is the issue.
4. Server Permissions & File Integrity
Incorrect permissions can prevent Apache from reading your override file:
- Set file permissions for
archive-product.phpto644and thewoocommercefolder to755 - Re-upload the file from your local copy to rule out corruption during transfer
- Add a quick debug snippet to
functions.phpto confirm WordPress can see the file:if (file_exists(get_stylesheet_directory() . '/woocommerce/archive-product.php')) { echo 'Override file is detected!'; } else { echo 'Override file NOT found—double-check your path!'; }
5. Enable WooCommerce Debug Log
Turn on WC’s debug mode to see exactly which template is loading:
- Add these lines to your
wp-config.php:define('WC_DEBUG', true); define('WC_DEBUG_LOG', true); - Check
wp-content/uploads/wc-logs/for a log file that will explicitly tell you whether it’s using the core template or your theme’s override.
Final Thought
Since this worked before the update, the most probable issues are either a template version mismatch, a child/parent theme mix-up, or a new hook in the updated Underscores theme that’s overriding the template path. Start with the child theme and file path checks—those are the most common culprits!
内容的提问来源于stack exchange,提问作者Suraj Rathod

