• wpress2010

    (@wpress2010)


    If I modify a copy of the includes/post-template.php file – and put it in the child theme’s folder, it does not appear to work. In the WP Codex, is there a list of files that can be modified via child themes? Or do I have to replicate the tree (directory) structure in the child theme’s folder somehow?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 4thhubbard

    (@4thhubbard)

    Core files such as includes/post-template.php cannot be directly overridden in a child theme. Instead, you typically need to create your own custom templates or functions in your child theme to achieve similar results.

    To modify functionality in files like post-template.php, consider the following options:

    1. Custom Template Files: Create a new template file in your child theme and use it where needed, such as for specific pages or post types.
    2. Hooks and Filters: Use WordPress hooks and filters in your child theme’s functions.php to modify or extend functionality without directly altering core files.

    Not all theme files can be overridden by placing copies in a child theme. The most common files you can replace are template files (like header.php, footer.php, page.php, etc.) and stylesheets. The WordPress Codex and the official Theme Handbook are great resources, but they don’t provide an exhaustive list of specific files. Generally, focus on overriding templates and using hooks for modifications.

    Yaman Jain

    (@yamanzyan)

    According to the file structure of a classic theme, template files should be located in the root folder of your theme:

    wp-content/themes/your-theme/[template].php

    You can refer to the folder structure guidelines here:

    Organizing Theme Files.

    To override a template file, you need to create the same file in the child theme, in the same location as it is in the parent theme.

    For more information on template hierarchy, refer to this guide:

    Template Hierarchy.

    Please note that only page templates can have custom templates, and they require the “Reading” settings to be set to a static page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.