我希望向输出中添加一个额外的ID:<div id="NEWID" class="kalec">
如果使用值调用快捷码no=0
i、 e。[photo no="0"]
我需要在输出中使用IF语句,但无法找出正确的语法。
function photo_shortcode($atts){
extract(shortcode_atts(array(
\'no\' => 1,
), $atts));
$no = ( $no != \'\' ) ? $no : 1;
$images = get_field(\'fl_gallery\');
$image = $images[$no];
if ($image) {
$credit = get_field(\'fl_credit\', $image[\'id\']);
return \'<div class="kalim"><img title="\' . esc_attr( sprintf( the_title_attribute( \'echo=0\' ) ) ) . \'" alt="\' . esc_attr( sprintf( the_title_attribute( \'echo=0\' ) ) ) . \'" src="\' . $image[\'url\'] . \'" />\' . (!empty($credit) ? \'<div [INSERT IF STATEMENT] class="kalec"><div class="kalca">\' . $image[\'caption\'] . \'</div><div class="kalcr">Credit:\' . $credit . \'</div></div>\': \'\' ) . \'</div>\' ;
}
}