php代码打印在屏幕wordpress上
我正在尝试制作一个儿童主题,一切看起来都很好,直到我将php版本从5.6改为7.2.1,所发生的事情是functions.php代码打印(回显)在屏幕上,如果我不理解,请查看图片 这是my functions.php,它只是wordpress中的一个示例,用于向您展示发生了什么:php代码打印在屏幕wordpress上,php,wordpress,Php,Wordpress,我正在尝试制作一个儿童主题,一切看起来都很好,直到我将php版本从5.6改为7.2.1,所发生的事情是functions.php代码打印(回显)在屏幕上,如果我不理解,请查看图片 这是my functions.php,它只是wordpress中的一个示例,用于向您展示发生了什么: <?function wporg_shortcode($atts = [], $content = null, $tag = '') { // normalize attribute keys, low
<?function wporg_shortcode($atts = [], $content = null, $tag = '')
{
// normalize attribute keys, lowercase
$atts = array_change_key_case((array)$atts, CASE_LOWER);
// override default attributes with user attributes
$wporg_atts = shortcode_atts([
"title" => "WordPress.org",
], $atts, $tag);
// start output
$o = '';
// start box
$o .= '<div class="wporg-box">';
// title
$o .= '<h2>' . esc_html__($wporg_atts['title'], 'wporg') . '</h2>';
// enclosing tags
if (!is_null($content)) {
// secure output by executing the_content filter hook on $content
$o .= apply_filters('the_content', $content);
// run shortcode parser recursively
$o .= do_shortcode($content);
}
// end box
$o .= '</div>';
// return output
return $o;
}
function wporg_shortcodes_init()
{
add_shortcode('wporg', 'wporg_shortcode');
}
add_action('init', 'wporg_shortcodes_init');
从
有些时候,Wordpress在Php中检测不到短标记
将版本从5.6更改为7.0。因此,您需要开始
只需在开始和结束时应用基本的php标记。替换开头启用短标记是一种不好的做法,它的关闭是有原因的#“一个就够了。”劳伦斯·切隆同意。我刚在谷歌上搜索了一下,找到了很好的描述:编辑了我的答案谢谢你们,你们救了我的命!