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