【发布时间】:2014-04-25 08:20:29
【问题描述】:
我正在努力弄清楚如何为我正在构建的主题创建带有选项的简码。
短代码创建一个容器,我想要一个“样式”参数,以便用户可以输入如下内容:
[container style="white"]content[/container]
我有三种样式:白色、透明和彩色,每种样式都应分别将类 style1、style2 和 style 3 添加到容器 html 中。这是我到目前为止在我的 php 中所拥有的:
// Container
function container($atts, $content = null) {
extract( shortcode_atts( array(
'style' => 'style2',
), $atts ) );
$return_string = '<section class="wrapper special container {$style}">'. do_shortcode($content) .'</section>';
wp_reset_query();
return $return_string;
}
我只是想通过注册 1 种样式来开始,但我什至还达不到这一点,更不用说三种不同的样式了!
目前这只是输出:
<section class="wrapper special container {$style}">[MY CONTENT]</section>
在 html 中 - 任何帮助或建议都会很棒。
【问题讨论】: