functions.php代码打印在屏幕wordpress上

时间:2018-07-19 03:44:25

标签: php wordpress

我正在尝试制作一个儿童主题,并且一切正常,直到我将php版本从5.6更改为7.2.1,这是在屏幕上打印(回显了)functions.php代码,然后检查图像,如果我没有道理。

This is the very top of my home page

这是我的functions.php,这只是wordpress的一个例子,向您展示发生了什么事:

<?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');

3 个答案:

答案 0 :(得分:1)

<?php而不是<?开始文件

答案 1 :(得分:0)

  

有时 Wordpress 不能检测到Php中的短标签<? ?>   将版本从5.6更改为7.0。因此,您需要启动<?php enclosing with the ?>

答案 2 :(得分:0)

只需在开始和结束时应用基本的php标记。

相关问题