【问题标题】:WordPress theme files within a subdirectory子目录中的 WordPress 主题文件
【发布时间】:2019-04-11 16:25:32
【问题描述】:

在当前项目中工作,其中有特定主题文件的 github 存储库。当我克隆 repo 时,它会将主题文件夹放在一个单独的目录中(应该如此),例如:

/wp-content/themes/projectfolder/themefolder

我想知道的是,是否可以让 WordPress 在子目录中查找该主题,而不必将整个 git 项目移动到 themes 文件夹中,因为那样会弄得一团糟。

【问题讨论】:

标签: wordpress wordpress-theming themes


【解决方案1】:

在你的 wp-config.php 文件中添加如下内容:

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
register_theme_directory('/wp-content/themes/projectfolder');

通常register_theme_directory(); 函数用于在插件内定义主题文件夹,但除此之外还有一些很好的用例。

【讨论】:

    猜你喜欢
    • 2017-01-10
    • 2020-07-28
    • 1970-01-01
    • 2020-06-20
    • 2021-12-04
    • 2021-10-09
    • 2017-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多