我想在每个循环总元素(<th rowspan=""><?php esc_html_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?></th>)后面插入一个序列号,从1开始,然后是2,3,4,...
为了更清楚起见,它应该对所有项目进行编号。这是代码,下面是我想要达到的图像。
<tr class="order-total recurring-total">
<?php if ( $display_th ) : $display_th = false; ?>
<th rowspan=""><?php esc_html_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?></th>
<td data-title="<?php esc_attr_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?>"><?php wcs_cart_totals_order_total_html( $recurring_cart ); ?></td>
<?php else : ?>
<th rowspan=""><?php esc_html_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?></th>
<td><?php wcs_cart_totals_order_total_html( $recurring_cart ); ?></td>
<?php endif; ?>
</tr>这是我想要实现的图像;"wiederkehrende gesamtsumme“=循环总数

发布于 2017-07-12 21:19:46
您需要使用for循环并打印循环中的表行
<?php for($i = 1; $i <= $n ; $i++) { ?>
<tr class="order-total recurring-total">
<?php if ( $display_th ) : $display_th = false; ?>
<th rowspan=""><?php esc_html_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?></th>
<td data-title="<?php esc_attr_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?>"><?php wcs_cart_totals_order_total_html( $recurring_cart ); ?></td>
<?php else : ?>
<th rowspan=""><?php esc_html_e( 'Recurring Total', 'woocommerce-subscriptions' ); ?></th>
<td><?php wcs_cart_totals_order_total_html( $recurring_cart ); ?></td>
<?php endif; ?>
</tr>
<?php } ?>然后,您可以在循环中的任意位置打印数字
<?php echo $i ?>https://stackoverflow.com/questions/45058625
复制相似问题