简体   繁体   English

WordPress Sage模板无法循环出ACF转发器字段

[英]WordPress sage template can't loop out acf repeater field

For some unknown reason I can't loop out a repeater field in my front-page.php. 由于某些未知原因,我无法在front-page.php中循环出一个Repeater字段。 I am using the sage theme as a base. 我以圣人主题为基础。

This is what my base.php looks like: 这是我的base.php的样子:

<?php

use Roots\Sage\Setup;
use Roots\Sage\Wrapper;

?>

<!doctype html>
<html <?php language_attributes(); ?>>
  <?php get_template_part('templates/head'); ?>
  <body <?php body_class(); ?> style="background-color: rgba(0,0,0,1);">
    <!--[if IE]>
      <div class="alert alert-warning">
        <?php _e('You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.', 'sage'); ?>
      </div>
    <![endif]-->

        <?php include Wrapper\template_path(); ?>

    <?php
      do_action('get_footer');
      get_template_part('templates/footer');
      wp_footer();
    ?>
  </body>
</html>

This is what my front-page.php looks like: 这是我的front-page.php的样子:

<div class="slider-circles">
  <?php if( have_rows('field_56e7d8bebb545') ): ?>
    <?php while ( have_rows('field_56e7d8bebb545') ) : the_row(); ?>
        <p id="slide1" data-bgimage="<?php the_sub_field('field_56e7d8cebb546'); ?>" class="transparent-circle slick-active"></p>
    <?php endwhile; ?>
  <?php endif; ?>
</div>

Funny thing is I've done this exact same thing a few days ago on an other project and everything worked fine. 有趣的是,几天前我在另一个项目上也做了同样的事情,并且一切正常。 I have absolutely no idea why it doesn't work now :/ 我完全不知道为什么现在不起作用:/

The default wordpress loop on front-page.php applies to the post content of the static page assigned to 'Settings > Reading ->Posts page'. front-page.php上的默认wordpress循环适用于分配给“设置>阅读->帖子页面”的静态页面的帖子内容。

Try dumping the values of the repeater field using 尝试使用以下方法转储转发器字段的值

<?php die(var_dump(get_field('field_56e7d8bebb545'))); ?>

If you're not seeing any values for the repeater field (and things like the_title() aren't working) then the loop probably isn't executing. 如果您没有看到Repeater字段的任何值(并且the_title()之类的东西不起作用),则循环可能没有执行。

Check that you've set the "Front page displays" to "a static page", as per the instructions here: https://codex.wordpress.org/Creating_a_Static_Front_Page 按照此处的说明,检查是否已将“首页显示”设置为“静态页面”: https : //codex.wordpress.org/Creating_a_Static_Front_Page

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM