Support » Themes and Templates » How to include subdirectories and their files in a child theme

  • Hey everyone,

    I’m building a child theme, and while I understand the basics, there’s one wrinkle I can’t get to work.

    I understand how to include theme files that reside inside the child theme’s main folder, such as style.css:


    But the theme I want to modify has a lot of files that reside within directories inside the parent theme, so I’ve an analogous file structure and file:


    But those files that reside inside subdirectories aren’t being carried over to my child theme.

    I’ve Googled my fingers off on this one, and while I’ve found some relevant threads, I’ve not been able to nail down a solid answer for this.

    Any guidance would be appreciated. For perspective:

    • I’m using DevPress’ Visual theme.
    • The modified files I want to carry over are related to BuddyPress 1.5.7. Specifically, I’ve modified the user profiles.

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you are trying to include a file from the parent theme:

    include get_template_directory() . '/folder/file.php';

    If you are trying to *override* folder/file.php in your child theme, you’ll need to look in DevPress Visual to find where and how file.php is included, then override the place that includes the parent.

    For example:

    parent-theme/includer.php calls include 'folder/file.php';.

    Override includer.php in your child theme.

    PDClark: Thanks so much for the detailed explanation. I’m working with the DevPress devs to figure this out, but in the meantime, I had a (potentially very silly) follow-up question:

    Where does that line of code go? In the site’s header? (Or barring a firm answer, where do such includes usually go in a theme?)

    Thanks again for your time!

    In a typical theme, they would be in functions.php. In more complex themes, you’ll typically see an include in functions.php to a larger library. I haven’t used any of the DevPress themes since Tung Do became the sole owner, but Justin Tadlock, who used to be involved with DevPress, includes his hybrid framework in functions.php like this:

    /* Load the core theme framework. */
    require_once( trailingslashit( TEMPLATEPATH ) . 'library/hybrid.php' );
    $theme = new Hybrid();

    That’s not to say DevPress themes will have the exact same code (I’d be surprised if they did) it’s just to give you an idea of what it might look like.

    Tung Do and his forum specifically for theme Visual would be the best resources in this case. Be sure to be specific about exactly what you’re trying to achieve with BuddyPress – I’m still unclear whether you’re looking to override or just include files.

    PD: I’m also in communication with Tung over at DevPress.

    And to clarify: I’m trying to override.

    Thank you again for the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to include subdirectories and their files in a child theme’ is closed to new replies.