Wordpress 子主题 - 覆盖不在主题根文件夹中的 php 文件 [英] Wordpress child theme - Overriding a php file which is not in the root folder of a theme
问题描述
我想通过子主题修改 Shop Isle 主题 (Wordpress) 的/inc/sections"文件夹中的 php 文件.我尝试了经典的方法,在我的子主题中创建一个同名的新 php 文件,但它不起作用.我读过有一种方法可以使用函数使子文件覆盖父文件.
我尝试过的所有方法都不起作用,或者像下面的这段代码会产生一些错误(滚动问题、空格等):
你知道解决方案吗?
<小时>front-page.php 代码:
/* 包装开始 */echo '';$big_title = get_template_directory() .'/inc/sections/shop_isle_big_title_section.php';load_template( apply_filters( 'shop-isle-subheader', $big_title ) ); 解决方案 好的,现在可以使用了!!!
我只需要在我的子主题中创建一个新的 front-page.php 并将 get_template_directory 的模板"替换为样式表"...
感谢您的帮助
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 ) );
解决方案 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
这篇关于Wordpress 子主题 - 覆盖不在主题根文件夹中的 php 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文