WordPress.org

Ready to get started?Download WordPress

Forums

Child theme directory structure (5 posts)

  1. webbrewers
    Member
    Posted 8 months ago #

    If I mimic a parent's directory structure in the child theme, do all the files override the parent or just css and page template files? I'm finding they don't.
    Example:
    Parent
    themes/theme1/style.css
    themes/theme1/pagetemplate.php
    themes/theme1/lib/file1.php

    Child
    themes/theme1-child/style.css OVERRIDES
    themes/theme1-child/pagetemplate.php OVERRIDES
    themes/theme1-child/lib/file1.php DOESN'T OVERRIDE

  2. missybunnie
    Member
    Posted 8 months ago #

    Usually it just over rides the css and template files. To change other files I believe you need to just point towards the file you want to override it in the functions or the page that references it.

  3. Spencer Hill
    Member
    Posted 8 months ago #

    missybunnie is correct. WordPress only overrides items from the Template Hierarchy (to the best of my knowledge).

  4. webbrewers
    Member
    Posted 8 months ago #

    Thank you both. Very helpful.
    I added this to the child functions file:
    require( get_stylesheet_directory() . '/inc/lib-content.php' );
    Seems to work - is that the best way to do it?

  5. Spencer Hill
    Member
    Posted 8 months ago #

    That seems adequate to me. I've not tried to override files that aren't in the Template Hierarchy before so I honestly don't know what the alternative would be.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.