简体   繁体   中英

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. I am using the sage theme as a base.

This is what my base.php looks like:

<?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:

<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'.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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