
<!doctype html>

<html <?php echo get_language_attributes(); ?>>
<?php echo $__env->make('partials.head', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<body id="rule" <?php body_class('renewal2023') ?>><?php wp_body_open(); ?>
  <div class="pacewrap">

    <div id="container">

      <article class="plr-0 col-12 col-md-10 offset-md-1 pb-5">
        <section class="main">
          <div class="col-12 col-md-10 offset-md-1">
            <div class="container">
              <header class="d-flex justify-content-between rule-title-wrap">
                <h1 class="page_title en"><?php echo get_the_title(); ?></h1>
                <?php if(is_page('rule')): ?>
                <div class="mb-3 mb-md-0">
                  <a class="btn-lang en" href="<?php echo e(home_url('/rule-english')); ?>">English</a>
                </div>
                <?php endif; ?>
              </header>
              <div class="content_page">
                <div class="term-of-use">
                  <?php
                  if ( have_posts() ) :
                    while ( have_posts() ) : the_post();
                      /* ① まずは表示中ページ（親でも子でも）の本文を出力 */
                      the_content();
                  
                      /* ② 親ページだった場合のみ子ページを取得して並べる */
                      if ( ! get_post()->post_parent ) {          // 親ページかどうか判定
                        $args = array(
                          'post_type'      => 'page',
                          'posts_per_page' => -1,
                          'post_parent'    => get_the_ID(),
                          'orderby'        => 'menu_order',
                          'order'          => 'ASC',
                        );
                        $child_pages = new WP_Query( $args );
                  
                        if ( $child_pages->have_posts() ) :
                          while ( $child_pages->have_posts() ) : $child_pages->the_post(); ?>
                  <div class="term-item">
                    <?php the_content(); ?>
                  </div>
                  <?php endwhile;
                        endif;
                        wp_reset_postdata();
                      }
                    endwhile;
                  endif;
                  ?>
                </div>
              </div>
            </div>
          </div>
        </section>
      </article>


      <?php wp_footer() ?>

    </div>

</body>

</html>
