【发布时间】:2014-03-23 02:41:56
【问题描述】:
我有一个简单的短代码,它接受一个属性和一些内容并返回一个 html 块:
function testimonial($atts, $content = null) {
extract(shortcode_atts(array(
"by" => 'Joe'
), $atts));
return '<p class="testimonial">'.$content.'<br /><span>— '.$by.'</span></p>';
}
add_shortcode("testimonial", "testimonial");
并且海报可以包含一个短代码,例如:
[testimonial by="Bob Smith"]This was great![/testimonial]
我的问题是,如何让用户在其内容中插入简单的html标签,如<b>或<br/>,如:
[testimonial by="Bob Smith"]Excellent restaurant.<br/>Try the desserts![/testimonial]
由于该函数当前将“内容”作为字符串返回,因此代码显示。
【问题讨论】:
标签: html wordpress wordpress-theming shortcode