2
votes

It seems like my Wordpress child theme in some cases refuses to use child files and still uses parent's files.

For example I want to override the themex.lesson that is located in the child_theme/framework/classes/themex.lesson.php folder

Parent's file is in the:

parent/framework/classes/themex.lesson.php folder

Changes that I make to the child_theme themex.lesson php are not reflected in live site. Other changes made to the child theme work perfectly fine. What could be causing this behavior?

1
Something similar happens to me. The other files that you edit and overwrite perfectly are in the root folder or are inside of folders or nested folders?Jabel Márquez
Files that work fine are in the root folder.Janusz Chudzynski
It's the same problem that I've. I keep looking, if I find a solution will tell you.Jabel Márquez
Thanks! I believe I found out why I have problems with overwriting the theme. My theme is set up to read always files from Framework folder of the paren't theme...Janusz Chudzynski
And where you change that your theme don't read the parent's files always?Jabel Márquez

1 Answers

0
votes

Referencing / Including Files in Your Child Theme

When you need to include files that reside within your child theme's directory structure, you will use get_stylesheet_directory(). Because the parent template's style.css is replaced by your child theme's style.css, and your style.css resides in the root of your child theme's subdirectory, get_stylesheet_directory() points to your child theme's directory (not the parent theme's directory).

Here's an example, using require_once, that shows how you can use get_stylesheet_directory when referencing a file stored within your child theme's directory structure.\

require_once( get_stylesheet_directory() . '/my_included_file.php' );

Source: https://codex.wordpress.org/Child_Themes