Question

I'm about to build a new site based on a theme close to what I'm looking for. I understand the concepts around child theming & have read the caveats about overriding php or css files like the one described here.

Using such workarounds and calls from functions.php, is it possible to build a "Frankenchild theme" by taking chunks of a second (would-be parent) theme and patching them into the child theme? I'm not quite asking about creating a child of two parents; the child would only have one "official" parent.

As an example: Start with a Gantry basic theme and add custom taxonomy search capabilities & search results formatting (say a card-based carousel). Is that stepping over the line into plugin development?

Was it helpful?

Solution

The canonical answer is that themes are for visuals only, the rest go in plugins.

In practice though, people bundle everything in a theme because it's easier to sell a zip you upload to the themes folder. In the future it will be possible to have themes that contain little to no PHP at all thanks to full site editing.

With that in mind, if you want to take functionality from an unrelated theme, nothing prevents you copying the files over, however, this doesn't mean that it will work. You'll almost certainly need to make adjustments so that styling looks right. You may need to implement PHP and JS changes to restore the functionality.

If you can move it to a plugin then that should always be the preferred choice.

If at any point you are tempted to load the code directly from the other themes folder via include or require, do not do this. It is extreme bad practice, and a very bad thing to do. There is no situation where this is a good idea. Avoid at all costs.

OTHER TIPS

That article you referenced is more or less about calling to something if it existed. That's fine when you are using plugins or functions that need to be called, however that's not the most important part of using a child theme.

The reason you would want to use a child theme is to add custom coding. You cannot use functions or snippets per se from the Parent. Adding snippets from a parent would render an error by calling a function twice.

The best approach is to make a plan and hook in your custom code to create Frankenstein child theme needs.

It's best to list your requirements of why you even need the child theme? What custom code are you going to need to add?

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top