【发布时间】:2017-10-18 13:18:04
【问题描述】:
我正在创建我网站的首页作为 wordpress 插件。 我想在我的插件中也包含一个 HTML 文件。我使用以下方法将 html 内容添加到我的插件中。
在 wp 4.8 版中:-
function displayHTMLpage() {
include( '\template\customPage.html' );
}
add_action( 'wp_enqueue_scripts', 'displayHTMLpage' );
在 wp 版本 4.8.1 中:-
function displayHTMLpage() {
$pageHTML = file_get_contents( plugins_url( '\template\customPage.html', __FILE__ ) );
echo $pageHTML;
}
add_action('wp_enqueue_scripts', 'displayHTMLpage');
现在上述方法在 4.8.2 中不起作用。在我升级到这个最新版本后,网站中没有加载 html 文件。 我真的不确定在 wordpress 插件中包含 HTML 文件的正确方法。请让我知道执行此操作的正确方法。
【问题讨论】:
-
如果你想在WordPress中使用html的输出,我建议你使用twig插件
-
您检查过错误吗?
-
警告:file_get_contents(/wp-content/plugins/plugin-searchForm/template/customPage.html):无法打开流:D:\home\site\wwwroot\ 中没有这样的文件或目录wp-content\plugins\plugin-searchForm\plugin-searchForm.php 在第 45 行我收到此错误。