【问题标题】:Copy and replicate changes of file on from parent theme to child theme in Wordpress在 Wordpress 中将文件更改从父主题复制和复制到子主题
【发布时间】:2017-05-20 03:42:35
【问题描述】:

我正在尝试反转基于我的测试位于内部的标题徽标标题的样式

/wp-content/themes/<theme-name>/inc/partials.php 

由于文件在Parent主题下,我需要将这个文件复制到子主题目录下

/wp-content/themes/<theme-name>-child/inc/partials.php

但是,我似乎无法在我的子主题中复制它。

例如,在Parent主题目录中,如果我反转下面的代码块:

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

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

我在 Parent 主题上看到,

partials.php

包含在

functions.php

按照下面的代码sn-p:

/** 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 );
}

在里面复制这段代码

functions.php

在子主题目录上不起作用。

我该怎么办?我错过了什么? TIA

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

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

    在使用子主题的情况下,该主题的绝对路径 将返回父主题目录。利用 get_stylesheet_directory() 获取子主题的绝对路径 目录。

    您可以将get_template_directory() 函数更改为get_stylesheet_directory() 函数并将所有这些文件复制到您的子主题中,但不建议这样做,因为您的修改会在更新主题后丢失。

    我建议您联系您的主题作者并询问他们将/inc/partials.php 文件覆盖到您的子主题中的解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-17
      • 2017-02-14
      • 1970-01-01
      • 2018-04-16
      • 1970-01-01
      相关资源
      最近更新 更多