Php echo不会正确应用于文本

时间:2017-10-03 21:55:56

标签: php wordpress shortcode

我创建了我的第一个WordPress插件,它很简单,这里是代码

<?php
/*
Plugin Name: blabla
*/
function wp_first_shortcode(){
    echo "Hello, This is your another shortcode!";
}
add_shortcode('first', 'wp_first_shortcode');
?>

在wp帖子中,我有一篇文章,如下:

text text text [first] text text

但我看到的结果是:

[first]
text text text text text

[first] - 是短代码,必须显示我的插件中的文字 - echo&#34;您好,这是您的另一个短代码!&#34 ;;

以下是直播示例www cpamethods.com/instagram-management /

的链接

1 个答案:

答案 0 :(得分:0)

在WordPress上的短代码上,返回,不要回显

<?php
/*
Plugin Name: blabla
*/
function wp_first_shortcode(){
    return "Hello, This is your another shortcode!";
}
add_shortcode('first', 'wp_first_shortcode');
?>

在使用短代码

之前,请务必先激活插件