1

如何创建具有多个属性值的简码?铁

[contact type="phone"]74847848[/contact]
 and 
[contact type="fax"]5565656565[/contact]


  function sc_kontakti($atts, $content = null) {




return '<div class="sckon '.$type.'">'.$content.'</div>';
 }
 add_shortcode("kontakti", "sc_kontakti");
4

2 回答 2

2

$atts 应该是一个数组,其中包含在您的简码中输入的所有属性。例如

[contact type="phone" number="8888888"]

应该给你

$atts['type']="phone"
$atts['number']="8888888"

然后您可以使用这些值来返回短代码输出的代码。

于 2011-11-24T21:37:42.743 回答
1

我正在使用 Shortcoder 插件。可以解决你的问题。他会自动创建您可以输入的值,并向编辑器添加一个按钮。这是链接:http ://wordpress.org/extend/plugins/shortcoder/

于 2013-02-21T12:05:40.623 回答