dongou3158 2018-07-20 13:30
浏览 103

在移动设备上切换显示/隐藏配置 - ACF中继器

I am using the ACF Repeater to create rows of images/content and to show/hide when clicked. Everything looks good on desktop screens, with a row of 3 images, when an image is clicked, the hidden div shows up below and the background color toggles on so you know which image's content you are looking at.

My problem, is I am trying to get the same functionality on mobile, but when an image is clicked, the content shows up under the 3rd div. I want to be below the image that was clicked. Since I am using the ACF repeater, my php script creates the parent div (3 across) first and then the hidden divs below.

I don't mind creating a separate html markup for mobile, I just can't figure out how to make it work with the ACF repeater.

<div class="staff">
<?php if (have_rows('staff_rows')):
while (have_rows('staff_rows')): the_row(); ?>
<div class="staff-wrap">
<div class="staff_images">        
<?php if (have_rows('staff_images')):
while (have_rows('staff_images')): the_row(); ?>
<a href="#/" class="<?php the_sub_field('staff_class'); ?> show staff-box"> 
<img src="<?php the_sub_field('staff_image'); ?>"><div class="image-box"><h3> 
<?php the_sub_field('staff_name'); ?></h3>
     <h3><?php the_sub_field('staff_position'); ?></h3></div>
  </a>

 <?php endwhile;
 endif; ?>
<?php if (have_rows('staff_bios')):
 while (have_rows('staff_bios')): the_row(); ?>
 <div class="bios">
<div class="wrap">
<div class="<?php the_sub_field('bio_class'); ?> row"><?php 
the_sub_field('bio_text'); ?></div>
</div>
</div>
<?php endwhile;
endif; ?>
</div>

http://toolboxdevmachine.com/TechNiche/about-us

Thanks for your help

  • 写回答

1条回答 默认 最新

  • doubei2340 2019-02-06 20:49
    关注

    I'm guessing you've already figured this out by now, in 2019. It looks like you are missing a few closing <div> tags, as well as ending your while loop and the primary conditional. I broke out the code, indented it and wrote it with the correct closing tags:

    <div class="staff">
      <?php if (have_rows('staff_rows')):
        while (have_rows('staff_rows')): the_row(); ?>
          <div class="staff-wrap">
            <div class="staff_images">        
              <?php if (have_rows('staff_images')):
                while (have_rows('staff_images')): the_row(); ?>
                  <a href="#/" class="<?php the_sub_field('staff_class'); ?> show staff-box"> 
                    <img src="<?php the_sub_field('staff_image'); ?>">
                    <div class="image-box">
                      <h3><?php the_sub_field('staff_name'); ?></h3>
                      <h3><?php the_sub_field('staff_position'); ?></h3>
                    </div>
                  </a>
                <?php endwhile;
              endif; ?>
              <?php if (have_rows('staff_bios')):
                while (have_rows('staff_bios')): the_row(); ?>
                <div class="bios">
                  <div class="wrap">
                    <div class="<?php the_sub_field('bio_class'); ?> row">
                      <?php the_sub_field('bio_text'); ?>
                    </div>
                  </div>
                </div>
              <?php endwhile;
            endif; ?>
          </div>
        </div>
      <?php endwhile; ?>
    <?php endif; ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同