如何在WordPress文本小工具中使用PHP

只需添加以下代码片段到你当前主题的functions.php文件

1 add_filter('widget_text', 'php_text', 99);
2 function php_text($text) { if (strpos($text, '<' . '?') !== false) { ob_start(); eval('?' . '>' . $text); $text = ob_get_contents(); ob_end_clean(); } return $text;}

 

posted @ 2015-12-20 15:52  申杰博客  阅读(332)  评论(0编辑  收藏  举报