【发布时间】:2020-02-20 15:12:33
【问题描述】:
所以我基本上需要在同一页面上多次使用具有不同属性值的相同简码。
所以在我的页面上,我有以下简码:
[sponsors type="Platinum"]
[sponsors type="Premium"]
[sponsors type="Plus"]
然后我有多个 if 语句,它们都声明了以下内容:
if ( $atts['type'] == 'Platinum' ) {
?>
<h2><?php echo 'working'?></h2>
<?php
} else {}
if ( $atts['type'] == 'Premium' ) {
?>
<h2><?php echo 'working'?></h2>
<?php
} else {}
if ( $atts['type'] == 'Plus' ) {
?>
<h2><?php echo 'working'?></h2>
<?php
} else {}
但我注意到,当我这样做时,这些值只是结合起来,并不特定于每个短代码,因为当我转储 $atts['type'] 时,我得到了这个字符串 'Platinum Premium Plus'。
所以不确定我还能如何做到这一点?
【问题讨论】:
-
我认为你需要一些关于这个的东西。你见过wordpress.stackexchange.com/questions/297003/…>吗?
标签: php wordpress shortcode wordpress-shortcode