我创建我的网站的头版一个WordPress插件HTML文件。 我想包括一个HTML文件也在我的插件。我已经使用下面的方法将HTML内容添加到我的插件。如何包括WordPress插件
在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输出,我建议您使用树枝插件 –
您是否检查错误? – ProEvilz
警告:file_get_contents(/ wp-content/plugins/plugin- searchForm /模板/ customPage.html):未能打开流:在d没有这样的文件或目录:\家\网站\ wwwroot的\的wp-content \插件\插件,searchForm \插件,searchForm.php线45 我米得到这个错误。 – Nidhin