Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Ovveride Wordpress parent theme files that are in other subdirectories with the child theme

What I would like so much to learn from you is how can I override specific files that are under subdirectories of a wordpress child theme. I see that, by having a file with the same name in the parent directory of the child theme overwrites that specific parent theme file, but its not working the same with the files in child theme subdirectories.

PS: I searched and re-searched google for solutions, and I tried and re-tried the 'solutions' that I found, but none is working.

Can you guys please help me?

Thank you so much! I love and appreciate all that you guys do!

7 Answers

missgeekbunny
missgeekbunny
37,033 Points

Are you talking about overriding template files or other files?

I am talking about overriding parent template files (that are in subdirectories) with a child theme. So, I am using I child theme and I want to know how can I override the parent-theme files that are not in the main theme folder, but in subdirectories.

I saw that, if you want to override a parent-theme files that is in the theme's main folder, it works very easy. You just put a file with the same name in the main childtheme folder and it gets overriden. But its not working in the same way with overriding files that are in parent-theme's subdirectories.

Hope you understand what I mean. If not, I will try to explain again. :)

missgeekbunny
missgeekbunny
37,033 Points

You will probably just need to copy the file that points to that file so you can reroute the file path towards the subdirectory in the child theme. Does that make sense?

Hey, I get what you say. But I found myself in a situation where No file from the main parent theme folder was pointing to that specific file. Probably it was pointing to another one from the same subdirectory, and that another one was pointing to that specific file.

What do I do in that case?

missgeekbunny
missgeekbunny
37,033 Points

Just wondering, probably should have asked sooner but what theme is your parent theme?

I don't talk about a specific theme here. This is a general problem or need that you have with any child theme, if the parent theme is a more complex one with more subfolders and stuff like that :)

missgeekbunny
missgeekbunny
37,033 Points

Well I'm asking because once you get into more complex themes the subfolders can be anything from pieces of template to functions that create the content. If it's not as simple as redirecting through copying the parent file and rewriting to meet the needs of the child theme then we need an idea of what kind of complexities are in the parent theme to help you figure out how to add the content you want to add.