在Wordpress中从父主题复制和复制上的文件更改到子主题

在Wordpress中从父主题复制和复制上的文件更改到子主题,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我正试图扭转标题的风格,标题的基础上,我的测试位于里面 /wp-content/themes/<theme-name>/inc/partials.php /wp content/themes//inc/partials.php 由于该文件位于父主题下,因此我需要在子主题目录下复制该文件 /wp-content/themes/<theme-name>-child/inc/partials.php /wp content/themes/-child/inc/parti

我正试图扭转标题的风格,标题的基础上,我的测试位于里面

/wp-content/themes/<theme-name>/inc/partials.php 
/wp content/themes//inc/partials.php
由于该文件位于父主题下,因此我需要在子主题目录下复制该文件

/wp-content/themes/<theme-name>-child/inc/partials.php
/wp content/themes/-child/inc/partials.php
然而,我似乎无法在我的孩子主题上复制它

例如,在父主题目录中,如果我反转以下代码块:

<h2 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h2>

这些更改会反映在主页的标题部分,但如果在子主题的文件版本上应用了相同的更改,则不会反映任何更改

我在家长主题上看到了

partials.php

包括在

functions.php

根据以下代码段:

/** Standard Includes */
$includes = array(

    '<other-files>.php',
    '<other-files>.php,

    'partials.php',
    '<other-files>.php',
);

foreach ( $includes as $file ) {
    require( get_template_directory() . '/inc/' . $file );
}
/**标准包括*/
$includes=数组(
“.php”,
"php先生,,
“partials.php”,
“.php”,
);
foreach($包含为$文件){
需要(获取模板目录()./inc/.$file);
}
将此代码复制到

functions.php

在子主题目录上,它无法工作

我该怎么办?我错过了什么?函数返回父主题路径。请检查引用的链接

在使用子主题的情况下,指向 将返回父主题目录。使用 获取子主题的绝对路径 目录

您可以将
get\u template\u directory()
函数更改为
get\u stylesheet\u directory()
函数,并将所有这些文件复制到子主题中,但不建议这样做,因为更新主题后您的修改将丢失

我建议您联系主题作者,向他们寻求一种解决方案,将
/inc/partials.php
文件覆盖到子主题中。

函数返回父主题路径。请检查引用的链接

在使用子主题的情况下,指向 将返回父主题目录。使用 获取子主题的绝对路径 目录

您可以将
get\u template\u directory()
函数更改为
get\u stylesheet\u directory()
函数,并将所有这些文件复制到子主题中,但不建议这样做,因为更新主题后您的修改将丢失

我建议您与主题作者联系,向他们寻求一种解决方案,将
/inc/partials.php
文件覆盖到您的子主题中