下面是我一直致力于运行短代码的代码。我已经尝试实施if()
声明,但没有任何效果。
我有两个输出。我想做的是,如果属性
(\'img\', \'user\', \'text\')
显示在快捷码中$output1
.否则,如果属性
(\'img\', \'text\', \'length\', \'material\', \'power\')
显示在快捷码中$output2
.function hire_equipment_func($atts) {
extract( shortcode_atts( array(
\'img\' => \'\',
\'user\' => \'\',
\'text\' => \'\',
\'length\' => \'\',
\'material\' => \'\',
\'power\' => \'\',
), $atts ) );
$atts = array_change_key_case((array)$atts, CASE_LOWER);
return $output1;
$output1 =
\'<div class="hire-equipment-item">
<div class="hire-equipment-item-img"><img src="\' . $atts[\'img\'] . \'" height=200px" width="200px" alt=""></div><br />
<div class="hire-equipment-item-user">\' . $atts[\'user\'] . \'</div>
<div class="hire-equipment-item-text">\' . $atts[\'text\'] . \'</div>
</div>\';
$output2 =
\'<div class="hire-equipment-item">
<div class="hire-equipment-item-img"><img src="\' . $atts[\'img\'] . \'" height=200px" width="200px" alt=""></div><br />
<div class="hire-equipment-item-user">\' . $atts[\'user\'] . \'</div>
<div class="hire-equipment-more-information">
<table class="hire-equipment-more-information-table" cellpadding="15px">
<tr>
<th>Length:</th>
<th>Material:</th>
<th>Power:</th>
</tr>
<tr>
<td> \' . $atts[\'length\'] . \' </td>
<td> \' . $atts[\'material\'] . \' </td>
<td> \' . $atts[\'power\'] . \' </td>
</tr>
</table>
</div>
</div>\';
}
add_shortcode( \'hire_equipment\', \'hire_equipment_func\' );
在此方面的任何帮助都将不胜感激!