我正在尝试将订单号输出到从图库标题生成的元素。foreach ( $item['gallery'] as $image ) { $lines = intval( apply_filters( 'caption_line', 1 ) ); for ( $line = 1; $line <= $lines; $line++ ) { $attachment_post = get_post( $image['id'] ); $image_caption = $attachment_post->post_excerpt; echo '<span class="dot1" onclick="currentSlide' . $item['unit_link'] . '(' . esc_attr( $line ) . ')">' . $image_caption . '</span>'; }}所以我需要为$line生成1,2,3,4...,但是对于我尝试过的东西,它只为所有元素输出1,更改1$lines= intval(apply_filters(“caption_line”,1));到较大的数字显示数字,但也复制它们。
1 回答

犯罪嫌疑人X
TA贡献2080条经验 获得超4个赞
只是想通了,这正是我一直在寻找的!
foreach ( $item['gallery'] as $key => $image ) {
$attachment_post = get_post( $image['id'] );
$image_caption = $attachment_post->post_excerpt;
$keyplus = $key+1;
echo '<span class="dot1" onclick="currentSlide' . $item['unit_link'] . '(' . $keyplus . ')">' . $image_caption . '</span>';
}
- 1 回答
- 0 关注
- 105 浏览
添加回答
举报
0/150
提交
取消