WordPress.org

Ready to get started?Download WordPress

Forums

Child theme - how to call a .php file in a subfolder? (5 posts)

  1. demonboy
    Member
    Posted 2 years ago #

    I understand how to call the style.css in my child theme

    /*
    Theme Name: suffusion-child
    Description: Child theme for the suffusion theme
    Author: Jamie Furlong
    Template: suffusion
    */
    
    @import url("../suffusion/style.css");

    And I understand that my child theme functions.php is appended to the main functions.php file.

    But how do I call the file 'post-header.php' which sits in a subfolder called 'custom' in my child-theme?

    I have read this article and am unsure if I am supposed to add require_once( get_stylesheet_directory(). '/custom/post-header.php' ); to my child functions.php. I have tried this already but nothing has changed.

    I know this is a simple problem, but what's the solution?

  2. Maruti Mohanty
    Member
    Posted 1 year ago #

    @demonboy Have U figured out a solution? I am in a similar problem. How can we edit/modify a file in the sub directory for a child theme.

    Even if we mirror the same folder structure the modifications done in a file in a sub directory doesnt reflect?

    Any help will be highly appreciated

    Thanks in Advance

  3. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    @Maruti - per the forum guidelines, please start your own thread. It's unlikely you have the identical situation as the OP and it works better for people here to only help one person at a time. Including a link to your site will also help people help you.

  4. Andrew Bartel
    Member
    Posted 1 year ago #

    The paths need to be the same in the child theme as they are in parent theme. For example, you have post-header.php. You need to duplicate it's path in the child theme. So, if it's directory path is /suffusion/custom/post-header.php, you can override it by creating a custom directory in your child theme: suffusion-child/custom/post-header.php.

  5. Maruti Mohanty
    Member
    Posted 1 year ago #

    @WPyogi .. Yeah I understand that, but what I see is no thread related to this issue has been solved, So I was trying to know if the concerned person has found a tweak or so.
    Regarding the link to the site, I dont think this is required as this is a problem which can easily be visualised.

    @Andrew Thanks for replying ... But this is exactly I have tried. But the files in the sub-directories in the child theme doesnt seem to get override. Cause I tried by simply replacing a text and it doesnt work.
    Have u really made it work this way?

    Any more inputs will help...
    Thanks for replying ... looking for some help

Topic Closed

This topic has been closed to new replies.

About this Topic