I am working at a WordPress setup on my local computer using AMPPS as my localhost. Using the Delta Theme I created a Child Theme (delta2-child). The initial setup works great. However, I need to change a file in the includes folder called home-slider.php.
location of original file:
c:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta\includes\home-slider.php
Location of Child Theme files:
c:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta2-child\includes\home-slider.php
If I move the home-slider file to the Child Theme folder[ delta2-child\includes\home-slider.php ], the theme still uses the Parent Themes home-slider file.
If I add the following to the CT's functions.php file:
require_once( get_stylesheet_directory_uri() . "/includes/home-slider.php" ); */
I get the following error:
Warning: require_once(C:\Program Files (x86)\Ampps\www\armstrong/wp-content/themes/delta/includes/home-slider.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta2-child\header.php on line 87
Fatal error: require_once() [function.require]: Failed opening required 'C:\Program Files (x86)\Ampps\www\armstrong/wp-content/themes/delta/includes/home-slider.php' (include_path='.;C:\php\pear') in C:\Program Files (x86)\Ampps\www\armstrong\wp-content\themes\delta2-child\header.php on line 87
Can any knowledgeable soul tell me how to refer to the home-slider file without gernerating the error above.
you can use get_template_part function
Change
to
Mo'men Is correct above. OP please mark him as the correct answer. The only error is he neglected to surround the file path with ' .
get_template_part('includes/home-slider');
Don't move the home-slider.php file from parent theme to child theme. Make a copy of this file into your child theme folder then do what you want to do in this file. It will override the functionality of parent file.
For further information about child theme please read: codex.wordpress.org/child-theme