admin管理员组文章数量:1327320
This is my first time asking a question here. I'm kinda stuck on how to do echo do_shortcode();
inside a shortcode.
I tried googling for an answer but to no avail.
I'd like to know if it is possible to echo a shortcode inside a shortcode. If it is, any pointer is much appreciated.
Thank you.
function cpa_haven_banner() {
return '
<ul class="list-group list-group-horizontal entry-meta">
<li class="list-group-item list-group-action-item">
<strong>Female</strong> <?php echo do_shortcode("[get_sheet_value location='LOAN!B7']"); ?>
</li>
</ul>
';
}
add_shortcode('cpa-haven', 'cpa_haven_banner');
This is my first time asking a question here. I'm kinda stuck on how to do echo do_shortcode();
inside a shortcode.
I tried googling for an answer but to no avail.
I'd like to know if it is possible to echo a shortcode inside a shortcode. If it is, any pointer is much appreciated.
Thank you.
function cpa_haven_banner() {
return '
<ul class="list-group list-group-horizontal entry-meta">
<li class="list-group-item list-group-action-item">
<strong>Female</strong> <?php echo do_shortcode("[get_sheet_value location='LOAN!B7']"); ?>
</li>
</ul>
';
}
add_shortcode('cpa-haven', 'cpa_haven_banner');
Share
Improve this question
asked Aug 10, 2020 at 12:18
yansusantoyansusanto
1092 bronze badges
2 Answers
Reset to default 1This should work:
function cpa_haven_banner() {
$shortcode = do_shortcode("[get_sheet_value location='LOAN!B7']");
return '
<ul class="list-group list-group-horizontal entry-meta">
<li class="list-group-item list-group-action-item">
<strong>Female</strong> ' . $shortcode .
'</li>
</ul>
';
}
add_shortcode('cpa-haven', 'cpa_haven_banner');
I would put all the markup in a variable, and return the result of passing that through do_shortcode
:
function cpa_haven_banner() {
$html = '
<ul class="list-group list-group-horizontal entry-meta">
<li class="list-group-item list-group-action-item">
<strong>Female</strong> [get_sheet_value location=\'LOAN!B7\']
</li>
</ul>
';
return do_shortcode( $html );
}
add_shortcode('cpa-haven', 'cpa_haven_banner');
本文标签: A shortcode nested inside a shortcode
版权声明:本文标题:A shortcode nested inside a shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742200379a2431844.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论