[英]do_shortcode is not working on my index.php
我在functions.php上注册了一个短代码
function offer_intro_shortcode ($atts, $content=null) {
$offer = shortcode_atts( array (
'title' => '',
'text' => '',
), $atts );
extract ($offer);
return '<div class="center gap">
<h3>'.$title.'</h3>
<p class="lead">'.$text.'</p>
</div>';
}
add_shortcode ('offer', 'offer_intro_shortcode');
然后我写在wordpress帖子:
[offer title='What We Offer' text='Look at some of the recent projects we have completed for our valuble clients']
然后我在我的index.php上查询这个短代码,如do_shortcode('[offer]')
但它没有用
尝试这个。
echo do_shortcode("[offer title='What We Offer' text='Look at some of the recent projects we have completed for our valuble clients']");
检查这是否有效。
在$ atts之后添加另一个参数,即短代码,这样就可以了。
$offer = shortcode_atts( array (
'title' => '',
'text' => '',
), $atts,'offer' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.