• 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter asammons

    (@asammons)

    Bump!

    Thread Starter asammons

    (@asammons)

    After some research, I think it’s because I’m trying to overwrite a non-template file. In other words, “file.php” isn’t a WordPress template file, so it doesn’t get looked at as a file that get’s overwritten.

    Is there a way to make every file in a theme be overwritable, even if it isn’t a template file? Maybe a function I can add in functions.php?

    Has anyone had any experience with this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Parent / Child theme from scratch’ is closed to new replies.