【问题标题】:How do I include a partial from a directory above a wordpress theme directory?如何从 wordpress 主题目录上方的目录中包含部分内容?
【发布时间】:2015-11-13 14:36:29
【问题描述】:

我现在设置了 3 个主题,我需要它们全部从同一来源继承部分主题,以便在我更改其中任何部分时同时更新所有三个主题。

我看到了

include("../../../includes/vital/partial.php");

在 single.php 或任何其他主题模板文件中不起作用。我得到的错误是:

警告:include():无法打开“../../../includes/vital/partial.php”以包含(include_path='.:/usr/local/Cellar/php56/5.6.8/ lib/php') 在第 7 行的 /Users/insertusername/Documents/Code/Projects/wordpress/wordpress-1/wp-content/themes/flowerz-mobile/single.php

我怎样才能做到这一点?

谢谢!

【问题讨论】:

  • 部分在哪里?什么文件夹?
  • 它位于 wordpress_root /includes/vital/

标签: wordpress themes wordpress-theming directory-structure


【解决方案1】:

由于 Wordpress 加载全部基于主要 index.php,因此下面的代码在每个主题中都适用于我。

include("includes/vital/partial.php");

没错,开头没有../

【讨论】:

  • 谢谢!我试图使用某种绝对路径 API 函数,如 get_bloginfo('wpurl')..etc 和类似的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-09
  • 2017-01-10
  • 1970-01-01
  • 2018-11-26
  • 1970-01-01
  • 2017-10-30
相关资源
最近更新 更多