Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues while creating child theme #37

Open
waqas-raza-dh opened this issue Nov 25, 2021 · 3 comments
Open

Issues while creating child theme #37

waqas-raza-dh opened this issue Nov 25, 2021 · 3 comments

Comments

@waqas-raza-dh
Copy link

Hello, I am trying to create a child theme. I have only the style.css file in my child theme folder and I am getting the following error from the parent theme (when I activate the child theme.) I have to add the functions.php in the child theme as well, later.

Warning: require(/themes/Child-Theme/app/AutoLoader.php): failed to open stream: No such file or directory in /wp-content/themes/Parent-Theme/functions.php on line 17
And my functions.php is similar to the original one here.

Can you please comment on this issue as what should go inside the functions.php of child theme.
Any help or guidance will be much appreciated.

Cheers.

@mishterk
Copy link
Owner

Hi,

Are you trying to create a child theme that uses this boilerplate theme as the parent? If so, that's not what this is built for. It's a boilerplate so you should just use it as a foundation and add all your own code to it. It isn't designed to be updated from this repo moving forward.

If you really really want to do it, you might just need to replace any uses of get_stylesheet_directory() with get_template_directory().

I'd suggest doing some simple debugging to learn about what is happening here — var_dump() is a great starting point or if you have xDebug set up, you can throw in some breakpoints and see what the code is doing line by line.

@waqas-raza-dh
Copy link
Author

Hello @mishterk, thank you so much for your response.

replacing get_stylesheet_directory() with get_template_directory()
&
get_stylesheet_directory_uri() with get_template_directory_uri()
makes the child theme work. But overriding the template files in the child theme does not work.
I tried the normal WordPress way of creating the same dir structure in the child theme to override the template files but that does not work. Any tips there?

Cheers

@mishterk
Copy link
Owner

Hi @waqas-raza-dh,

Are you using get_template_part() to load your templates? If so, that should work I think. If you're using the built in view utility to load templates, that won't defer to a parent/child hierarchy as it doesn't use WordPress' functions under the hood.

So, instead of using View::render(), try get_template_part( $slug, null, $args). Not sure if this will work as a direct replacement so you may be left tinkering to figure the rest out.

I mentioned this already but to reiterate: this isn't built with child themes in mind — it's built to be a foundation for direct modification for a custom theme. You would be much better off just cloning this and working directly on the theme itself instead of child-theming as it will save you the hassle here.

The other thing to keep in mind is that it'll likely change dramatically so if you're using it as a parent theme with the intention of keeping it up to date as the boilerplate evolves, you'll run into breaking changes down the track. Backwards compatibility isn't important for a boilerplate so it isn't a focus when I'm working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants