0
votes

I have a child theme setup in wordpress and the style.css and functions.php in the child theme are working correctly. I now want to overwrite other template .php files with the versions in the child theme. I can't seem to make these files overwrite the parent theme however.

child theme functions.php:

<?php
//enqueue styles
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 'overwrite' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
//overwrite template pages
function overwrite() {
    wp_enqueue_script( get_template_directory_uri() . '/inc/structure/hooks.php' );
    wp_enqueue_script( get_template_directory_uri() . '/inc/structure/header.php' );
}

I have a hooks.php and header.php in /child-theme/inc/structure/

1

1 Answers

1
votes

For a child-theme you do not need to enqueue any template (PHP) files, simply add a PHP file to your child-theme with exactly the same name and path as the one you are trying to overwrite in your parent theme and it will naturally replace it.