[英]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.