为什么我的循环破坏了下面的css?

时间:2021-04-08 作者:Marcel

            <?php
                    /**
                     * My Orders - Deprecated
                     *
                     * @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
                     * @package WooCommerce\\Templates
                     */

                    defined( \'ABSPATH\' ) || exit;

                    $customer_orders = get_posts(
                        apply_filters(
                            \'woocommerce_my_account_my_orders_query\',
                            array(
                                \'numberposts\' => $order_count,
                                \'meta_key\'    => \'_customer_user\',
                                \'meta_value\'  => get_current_user_id(),
                                \'post_type\'   => wc_get_order_types( \'view-orders\' ),
                                \'post_status\' => \'wc-processing\',
                            )
                        )
                    );

                    if ( $customer_orders ) : ?>
        <div id="active-orders" class="ras__item">
          <p class="title">Активные заказы</p>
          <div class="ras-table">
            <div class="ras-thead">
              <div class="ras-tr">
                <span class="ras-td">Дата заказа</span>
                <span class="ras-td">Номер заказа</span>
                <span class="ras-td">Статус</span>
                <span class="ras-td">Доставка</span>
                <span class="ras-td">Сумма</span>
                <span class="ras-td">Залог</span>
              </div>
            </div>
            <div class="ras-tbody">
            <?php
                                    foreach ( $customer_orders as $customer_order ) :
                                        $order      = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
                                        $item_count = $order->get_item_count();
                                        ?>
              <div class="ras-tr">
                <span class="ras-td"><time datetime="<?php echo esc_attr( $order->get_date_created()->date( \'c\' ) ); ?>"><?php echo esc_html( wc_format_datetime( $order->get_date_created() ) ); ?></time></span>
                <span class="ras-td"><a href="<?php echo esc_url( $order->get_view_order_url() ); ?>"><?php echo _x( \'#\', \'hash before order number\', \'woocommerce\' ) . $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a></span>
                <span class="ras-td status orange"><?php echo esc_html( wc_get_order_status_name( $order->get_status() ) ); ?></span>
                <span class="ras-td"><?echo $order->get_shipping_method();?></span>
                <span class="ras-td"><?php
                     /* translators: 1: formatted order total 2: total order items */
                     printf( _n( \'%1$s\', \'%1$s\', $item_count, \'woocommerce\' ), $order->get_formatted_order_total(), $item_count ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
                     ?></span>
                <span class="ras-td"><?php printf( get_field( \'zalog\', $order_id ) ); ?></span>
                <span class="ras-td read-more">
                    <?php
                   $actions = wc_get_account_orders_actions( $order );

                   if ( ! empty( $actions ) ) {
                   foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
                   echo \'<a href="\' . esc_url( $action[\'url\'] ) . \'" class="button \' . sanitize_html_class( $key ) . \'">\' . esc_html(\'Подробнее\') . \'</a>\';
                        }
                   }
                   ?>
                </span>
              </div>
            </div>
            <?php endforeach; ?>
          </div>
        </div>
        <?php endif; ?>
        <div id="archive-orders" class="ras__item">
          <p class="title">Архив заказов</p>
          <div class="ras-table">
            <div class="ras-thead">
              <div class="ras-tr">
                <span class="ras-td">Дата заказа</span>
                <span class="ras-td">Номер заказа</span>
                <span class="ras-td">Статус</span>
                <span class="ras-td">Доставка</span>
                <span class="ras-td">Сумма</span>
                <span class="ras-td">Залог</span>
              </div>
            </div>
            <div class="ras-tbody">
              <div class="ras-tr">
                <span class="ras-td">02.10.2020</span>
                <span class="ras-td">#1001005</span>
                <span class="ras-td status">Выполнен</span>
                <span class="ras-td">Самовывоз</span>
                <span class="ras-td">20 000 ₽</span>
                <span class="ras-td">5 000 ₽</span>
                <span class="ras-td read-more">
                  <a href="">Подробнее</a>
                </span>
              </div>
              <div class="ras-tr">
                <span class="ras-td">02.10.2020</span>
                <span class="ras-td">#1001005</span>
                <span class="ras-td status">Выполнен</span>
                <span class="ras-td">Самовывоз</span>
                <span class="ras-td">20 000 ₽</span>
                <span class="ras-td">5 000 ₽</span>
                <span class="ras-td read-more">
                  <a href="">Подробнее</a>
                </span>
              </div>
              <div class="ras-tr">
                <span class="ras-td">02.10.2020</span>
                <span class="ras-td">#1001005</span>
                <span class="ras-td status">Выполнен</span>
                <span class="ras-td">Самовывоз</span>
                <span class="ras-td">20 000 ₽</span>
                <span class="ras-td">5 000 ₽</span>
                <span class="ras-td read-more">
                  <a href="">Подробнее</a>
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
CSS在循环外部被破坏

1 个回复
SO网友:Nigel Rodgers

看起来您有一个额外的结束div标记和section标记。将html注释添加到结束div标记以跟踪它们属于哪个div,如下所示:

                </div> <!-- /.ras-tr -->
            </div> <!-- /.ras-tbody -->
        </div> <!-- /.ras-table -->
    </div> <!-- /.ras-item -->
还要验证没有其他模板可能具有额外的开始部分和div标记。

相关推荐

Bootstrap grid while loop

我用bootstrap制作了一个网格,我想在其中显示5个不同的帖子,但出于某种原因,它复制了网格,并且每个网格显示一个帖子。第一幅图显示了它如何开始将网格复制5次,而不是仅在这些列中显示5篇文章。第二张图片显示了我想如何工作。 <?php get_header(); ?> <main> <div class=\"container\"> <div class=\"row\"> <?php &