【问题标题】:Wordpress child theme for second installation用于第二次安装的 Wordpress 子主题
【发布时间】:2017-08-18 22:20:25
【问题描述】:

我们为我们的主网站安装了具有自己主题的 WordPress。我现在想在我想在那里使用主网站主题的子文件夹中安装另一个 WordPress。
所以我制作了一个包含 3 个文件的新主题:

index.php
style.css
functions.php

我指的是新安装index.php文件中的主要网站主题文件(例如header.php):

    <?php
//Checking if file exist
if ( file_exists( get_stylesheet_directory() . '/../../../../wp-content/themes/First/header.php') ) {
    //Require file if it exist, 
    require_once( get_stylesheet_directory() . '/../../../../wp-content/themes/First/header.php' )
} else {
    /* Echo something if file doesn't exist, if the message wasn't displayed and you still get 500 error then there's some wrong on the php file above*/
    _e('File not found');
}
?>

但是,无论如何,这会返回 500 错误,我可以这样做吗?在一个文件夹中新安装的 WordPress 上使用另一个 WordPress 安装主题?

【问题讨论】:

    标签: php wordpress wordpress-theming


    【解决方案1】:

    请使用register_theme_directory()函数并使用绝对路径。

    另请参阅:https://wordpress.stackexchange.com/questions/83102/how-do-you-change-the-theme-location

    【讨论】:

    • 我应该在我的functions.php文件中使用这个函数吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 2016-11-07
    • 2012-09-12
    相关资源
    最近更新 更多