Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否允许在wordpress短代码内容中使用HTML标记?_Html_Wordpress_Wordpress Theming_Shortcode - Fatal编程技术网

是否允许在wordpress短代码内容中使用HTML标记?

是否允许在wordpress短代码内容中使用HTML标记?,html,wordpress,wordpress-theming,shortcode,Html,Wordpress,Wordpress Theming,Shortcode,我有一个简单的短代码,它接受一个属性和一些内容,并返回一个html块: function testimonial($atts, $content = null) { extract(shortcode_atts(array( "by" => 'Joe' ), $atts)); return '<p class="testimonial">'.$content.'<br /><span>&mdash; '.$by.'</span>

我有一个简单的短代码,它接受一个属性和一些内容,并返回一个html块:

function testimonial($atts, $content = null) {
extract(shortcode_atts(array(
    "by" => 'Joe'
), $atts));
return '<p class="testimonial">'.$content.'<br /><span>&mdash; '.$by.'</span></p>';
}
add_shortcode("testimonial", "testimonial");
我的问题是,如何允许用户在其内容中插入简单的html标记,例如

,例如:

[testimonial by="Bob Smith"]Excellent restaurant.<br/>Try the desserts![/testimonial]
[推荐人=“鲍勃·史密斯”]这家餐厅很棒。
尝尝甜点吧![/证明]

由于函数当前以字符串形式返回“内容”,因此代码将显示。

您可以允许自己解释短代码,例如,如果用户键入
[b]
,您可以在输出中将其替换为
。也就是说,
$content
可以

str_replace("[b]","<strong>", $content);
stru替换(“[b]”,“”,$content);
这只是一个粗略的例子

str_replace("[b]","<strong>", $content);