Question

I am trying to overwrite a template file (tpl-footer.php) in my child-theme. According to the wordpress docs this should be possible just by adding the file with the same name and the same path into the child-theme. When I do so, nothing happens.

The theme I use is snsnitan

Does anyone know what I am missing? Do I need to overwrite more files?

The footer.php in parent theme has just:

<?php wp_footer(); ?>
</body></html>
Was it helpful?

Solution

If the file is included via get_template_part or a part of the template hierarchy, then yes, create a file with the same name in a child theme and WordPress will preferentially load that file.

If the file is included via include/require, then no, those are PHP language features, not WordPress functions, there is no way to intercept or override them so that your file is loaded instead. Either fork the theme or contact the theme support route. The author may have provided alternative methods of overriding the template, or be able to add support for it.

Remember, child themes let you preferentially load child theme templates via the template hierarchy and get_template_part. They can't auto-replace arbitrary PHP files, CSS, JS etc files by putting them in a child theme and expecting them to be used instead

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