Stop Woocommerce from Pulling from the Default single.php

“Help! My content-single-product.php and single-product.php files, which I have in the correct woocommerce folder, in my theme folder, is using single.php!”

This is a real head scratcher, and you wouldn’t be the first developer to go bald with all of that scratching of the scalp. Luckily, the solution to getting Woocommerce to just use the code in those files is simple.

But why is it happening? Woocommerce strives to work with any theme, whether the developers of that theme have explicitly stated that it’s compatible with the plugin or not.

To fix it, all you have to do is declare support for Woocommerce. Paste this into your functions.php file. You’ll need a child theme setup if you’re using a theme you didn’t personally build.

// declare Woocommerce support
if (function_exists('is_woocommerce')) {
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );

That’s it, enjoy!

Up Next: How to Programmatically Exclude Posts from the Yoast SEO for WordPress Plugin