我想用下面的簡碼:WordPress的嵌套簡碼內容
[section]
<h1>Section body content</h1>
[section_footer]<p>Section footer content</p>[/section_footer]
[/section]
所以,我添加了以下簡碼回調:
function sec_cb ($att, $content = null) {
// ...
return
'
<section>
<div class="sec-body">
'.strip_shortcodes($content).'
</div>
'.do_shortcode($content).'
</section>
';
}
function sec_footer_cb ($atts, $content = null) {
return
'
<div class="sec-footer">
'.$content.'
</div>
';
}
add_shortcode('section', 'sec_cb');
add_shortcode('section_footer', 'sec_footer_cb');
但輸出是:
<section>
<div class="sec-body">
<h1>Section body content</h1>
</div>
<h1>Section body content</h1>
<div class="sec-footer">
<p>Section footer content</p>
</div>
</section>
我該如何修復它並在頁腳中打印頁腳短代碼內容?
也許你已經在同一個鉤子'do_shortcode'上註冊了這兩個函數。請更新帖子並設置你如何/在哪裏調用函數'sec_cb'和'sec_footer_cb'。 –
Hi @JoseCarlosRamosCarmenates,請檢查更新 – DDE
現在你正在打印的頁腳正確的內容見:'
節內容
''請輸出需要什麼? –