我使用这种结构来实现自己的短代码:
function column_with_icon($atts, $content = null) {
extract(shortcode_atts(array(
\'icon\' => \'onebit_03\'
), $atts));
return \'<div class="column3">
<img class="features-icon" alt="icon" src="\' . get_bloginfo("template_url") . \'/images/icons/\' . $icon . \'.png"/>
<div class="feature-content">\' . $content . $icon . \'</div>\';
}
add_shortcode(\'column-icon\', \'column_with_icon\');
当我尝试添加这样的内容时:[column-icon icon="onebit_13"]
<h3>What is Lorem ipsum?</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<a href="#" class="main-theme-link">Learn more</a></div>
[/column-icon]
“icon”属性的默认值未被覆盖,我得到的值等于“onebit\\u 03”,而不是“onebit\\u 13”,对此我能做些什么?UPDATE以下是我用来检索和显示数据的代码:
function skible_load_special_offer_section() {
$content = get_option("prc_speciall_offer_text", true);
if (get_option("prc_show_special_offer_section")) {
echo stripslashes(do_shortcode(\'<!--Start Special offer (in border) content-->
<div class="border-top"></div>
<div class="border-middle">
<div class="special-offer-area">
<div class="special-offer-image-left">
<img alt="image" src="\' . get_bloginfo("template_url") . \' /colors/magic_night/special-offer-image.png"/>
</div>
<div class="special-offer-content-right">\' . $content . \'</div>
<div class = "clear"></div>
</div>
</div>
<div class = "border-bottom"></div>
<!--End Special offer (in border) content-->\'));
}
}