• anonymized-14293447

    (@anonymized-14293447)


    I have a theme that has it’s own plugin to output templates/header/footer, and also has some premium plugins licenced and hardcoded into it.
    My problem is that I cannot override such templates via my child-theme. I have tried with a custom directory/template under the child-theme, but changes won’t apply. I have read all possible tutorials which just confirm that folder structures need to be duplicated but none explains if any snippets to write/register are needed.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Normally, the child theme would override by using the same named template in the same folder structure as the parent. But a plugin supplying some templates doesn’t work in the same way. For a plugin to supply templates, it has to add code to filter which template is used, so that it comes from the plugin. That means the child theme would be ignored also.
    This is why the requirements for the Theme Repository state that a theme can’t include plugins, and the theme must be child theme friendly.

    To get something to work with that theme (which is not supported here), you’ll need to ask the author.
    Or you could switch themes to one that does things in a more flexible way, that is compatible with standard child theming.

    Thread Starter anonymized-14293447

    (@anonymized-14293447)

    I believe the theme is very much standardized. I also ask the author and they confirmed overrides are to be put in childtheme. But that is a vague answer (no mention of filters) and I don’t understand why the changes are not applied. This is a problem with any plugin that needs customization, and no matter if a theme is premium or free, I have not found a decent explanation/tutorial.

    Thread Starter anonymized-14293447

    (@anonymized-14293447)

    …I read somewhere the following sentence: You could check if the calling function or the shortcode is pluggable – Then you could just call your own template
    Can anyone translate that in a dum language?

    I also ask the author and they confirmed overrides are to be put in childtheme.

    This is the generic answer, but might not apply when used with the plugin.

    I don’t understand why the changes are not applied.

    I explained how a plugin would have to work in order to supply templates. Since I didn’t see the code, I can’t get much farther. You’ll have to ask the author.

    You could check if the calling function or the shortcode is pluggable

    The theme or plugin can make their function pluggable, which means that their function has an if statement around it, checking whether the function exists yet or not. Since child themes are loaded before the parent theme is, the child can define the function first, and when the parent checks, it will already exist, so the parent function won’t be defined. In this way, the child “overrides” the parent function. But this only works when the if statement is there, because having two functions with the same name is a fatal error. But again, plugins load before themes, so even if the plugin’s function is pluggable, the child theme couldn’t define it.
    But filters don’t have that problem. There can be many filter functions for the same filter.

    Please ask the vendor for support, since we can’t see the code here, so we don’t support it here. And you paid them for it, so they should provide the support.

    Thread Starter anonymized-14293447

    (@anonymized-14293447)

    Let me ask you one last thing before you go, without going too much into the custom-plugin: why the following logic is not working?
    > parenttheme/templates/footers/footer1.php
    > childtheme/templates/footers/footer1.php
    There’s nothing misterious in that logic, yet the latter footers1.php doesn’t apply changes.

    You said it in the first line:

    I have a theme that has it’s own plugin to output templates/header/footer

    Thread Starter anonymized-14293447

    (@anonymized-14293447)

    yes, but footer1.php IS coming from the custom plugin, only it’s put under the parent theme…. and that causes me further confusion

    From what you said, the theme is standard (child will override), but the plugin probably isn’t (child will not override).
    Please ask the author, as it is not what we do here to support code we can’t see.

    Thanks for the great plugin!
    I have the same problem, you can clarify how override the templates in a child-theme. Thanks
    PS In general I can’t find a documentation of the plugin

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘templates not overridden from childtheme’ is closed to new replies.