5

I am using Storefront theme (But question isn't specify to this theme, I am asking question for any theme).

I can easily override files like header.php, footer.php using child theme(just copy and paste the file).

But I can't override any files which is on "inc" folder (any folder). How can I override those files?

1

2 Answers 2

6

WordPress only looks for the default template files while loading the child theme. So does woocommerce.

Any extra folder or file that exists in your parent theme can not be overridden, unless the developer is using actions and filters that allows you to hook into them. Therefore, a simple require() or include() can't be overridden by a child theme.

What you can do is to track the template file that is calling the files from the inc folder, and then override those in your theme's folder. You might need to go as back as functions.php.

For a complete list of default template files, take a look at the template hierarchy.

2
  • Are you sure about this? I was able to override similar files in some themes. Nov 5, 2019 at 3:43
  • What kind of files? Maybe the theme provided support for this, by checking if the file exists in the child-theme folder ( woocommerce does something similar to this )
    – Johansson
    Nov 6, 2019 at 12:49
0

Certain parent themes use locate_template(), which does allow child themes to override non-default files in the parent theme. It's just something the parent theme has to support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.