1
我正在尝试使用wordpress在页面中包含php文件。 但是,一切都没有奏效。如何在wordpress页面上添加php文件
我发现了一些有趣的东西,但它不起作用,我想知道如果你能帮助我。
基本上,我试图做一个插件来添加一个页面中的PHP文件。
<?php
// include PHP file
function PHP_Include($params = array()) {
\t extract(shortcode_atts(array(
\t 'file' => 'default'
\t), $params));
\t
\t ob_start();
\t include(get_theme_root() . '/' . get_template() . '/folder' . "/$file.php");
\t return ob_get_clean();
}
// register shortcode
add_shortcode('phpinclude', 'PHP_Include');
?>
我不知道怎么在这里添加PHP代码,对不起。
我在我的页面输入[phpinclude file ='namefile']。
https://codex.wordpress.org/Writing_a_Plugin可能? –
我正在阅读,但我不确定要理解。 上面的代码似乎没有这么复杂,但没有任何工作,我不知道它是什么。 – AlexCold