Wordpress child theme - Overriding a php file whic

2019-08-17 03:44发布

问题:

I would like to modify a php file which is in "/inc/sections" folder of the Shop Isle theme (Wordpress) through a child theme. I tried the classic way by creating a new php file with the same name in my child theme but it s not working. I ve read there is a way to make the child file overriding the parent one using a function.

All what I ve tried didn t work or like this code below create some bugs (scrolling problem, blank space, etc):

<?php
require get_stylesheet_directory() . '/inc/sections/shop_isle_big_title_section.php' ;
?> 

Do you know a solution ?


front-page.php code:

/* Wrapper start */

echo '<div class="main">';
$big_title = get_template_directory() . '/inc/sections/shop_isle_big_title_section.php';
load_template( apply_filters( 'shop-isle-subheader', $big_title ) );

回答1:

Ok it s working now!!!

I just had to create a new front-page.php in my child theme and replace "template" of get_template_directory with "stylesheet" ...

Thanks for your help



标签: php wordpress