组内的中继器,且两者都在组内ACF Wordpress。

问题描述 投票:0回答:1

我正在努力 ACF 在Wordpress的插件,我有这个HTML代码,分为3部分。母集团 在这个父集团内部也有 儿童团 里边 子女组复读机.我试着像这样解决它 [4]但它没有工作。这几张图片可以解释更多

形象1

图片二

形象三

<!--The Parent Group (section2_technology)-->
<div class="section2">
  <div class="container">
    <div class="right">
      <div class="frame">
        <!-- The (qoute) text -->
        We use modern, proven technologies and approaches that allow us to effectively extend and scale our products.
      </div>
    </div>
    <div class="left">
      <div class="top">
        <hr>
        <span>MOBILE</span>
        <hr>
      </div>
      <!-- The Child Group class='mobile' -->
      <div class="bottom" id="mobile">
        <div data-aos="flip-up">
          <div class="slide-down frame1">
            <div class="main-hover">
              <div class="mobile">
                IOS
              </div>
              <div class="split"></div>
              <div class="content-div">
                <div class="slide-down__top">
                  <!-- The Repeater class='type' -->
                  <div class="type">
                    <img src="" alt="" class="mobileicons-img">
                    <div class="name"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div data-aos="flip-down" data-aos-delay="200">
          <div class="slide-down">
            <div class="main-hover">
              <div class="mobile">
                ANDROID
              </div>
              <div class="split"></div>
              <div class="content-div">
                <div class="slide-down__top">
                  <!-- This is the repeater class='type' -->
                  <div class="type">
                    <img src="" alt="" class="mobileicons-img">
                    <div class="name">Java</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
php wordpress advanced-custom-fields acfpro
1个回答
0
投票

你的PHP应该看起来像这样。

<?php if ( have_rows('parent-group') ): ?>
    <!-- html before -->
    <?php while ( have_rows('parent-group') ) : the_row(); ?>

        <?php if ( have_rows('child-group') ): ?>
            <!-- html before -->
            <?php while ( have_rows('child-group') ) : the_row(); ?>

                <?php if ( have_rows('repeater') ): ?>
                    <!-- html before -->
                    <?php while ( have_rows('repeater') ) : the_row(); ?>

                        <!-- item contents -->
                        <?php the_sub_field("image") ?>
                        <?php the_sub_field("title") ?>
                        <!-- item contents -->

                    <?php endwhile; ?>
                    <!-- html after -->
                <?php endif; ?>

            <?php endwhile; ?>
            <!-- html after -->
        <?php endif; ?>

    <?php endwhile; ?>
    <!-- html after -->
<?php endif; ?>

记住have_rows()默认为当前文章的行数。

要从不同的帖子中获取行,使用:have_rows('key', $postID)。

或者如果你使用选项页面:have_rows('key', "options");

© www.soinside.com 2019 - 2024. All rights reserved.