Parent / Child theme from scratch
-
I’m building a parent theme from scratch that I plan on using for multiple sites. The parent theme will have an ‘includes’ folder in it, following this structure:
parentTheme/includes/file.php
I will occasionally want to overwrite files in the parent theme by using files from the child theme. I have the child theme set up the same way:
childTheme/includes/file.php
Right now, I’m having trouble overwriting ‘includes/file.php’ with my child theme.
In my parent theme, I’m calling the file.php file by doing this:
<?php include('includes/file.php'); ?>
Ideally, I want to have a very minimal child theme, and if I choose to overwrite ‘includes/file.php’, I can just upload it to my child theme. If I don’t upload it, the parent’s ‘includes/file.php’ will be used.
I have this set up, and my style.css file works, but none of the “included” files get overwritten.
I know there are <?php get_template_directory_uri(); ?> and <?php get_stylesheet_directory_uri(); ?>, but I don’t have those in my parent theme, as they seem inflexible to me, meaning if I use the <?php get_stylesheet_directory_uri(); ?>, it seems like I need to have a file in my child directoy, and if I use <?php get_template_directory_uri(); ?>, the child file doesn’t overwrite the parent.
Can anyone give me a pointer on how to set this up and call these files correctly?
- The topic ‘Parent / Child theme from scratch’ is closed to new replies.