簡體   English   中英

WordPress Sage模板無法循環出ACF轉發器字段

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

由於某些未知原因,我無法在front-page.php中循環出一個Repeater字段。 我以聖人主題為基礎。

這是我的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>

這是我的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>

有趣的是,幾天前我在另一個項目上也做了同樣的事情,並且一切正常。 我完全不知道為什么現在不起作用:/

front-page.php上的默認wordpress循環適用於分配給“設置>閱讀->帖子頁面”的靜態頁面的帖子內容。

嘗試使用以下方法轉儲轉發器字段的值

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

如果您沒有看到Repeater字段的任何值(並且the_title()之類的東西不起作用),則循環可能沒有執行。

按照此處的說明,檢查是否已將“首頁顯示”設置為“靜態頁面”: https : //codex.wordpress.org/Creating_a_Static_Front_Page

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM