高级自定义字段|在转发器中发布对象不起作用

时间:2018-09-13 17:44:05

标签: php wordpress repeater advanced-custom-fields

我正在使用wordpress和“高级自定义字段”,并且试图在acf中继器中显示发布对象,但不幸的是,它仅输出中继器的第一行。有人知道为什么吗?

这是我的代码:

<?php if( have_rows('repeater') ): ?>
<?php while( have_rows('repeater') ): the_row(); 
    // vars
    $repeater = get_sub_field('repeater'); ?>
    <?php $repeaterGroup = get_sub_field('repeater_group'); ?>
    <div class="box25-75">
        <div class="col col1">
            <?php $colLeft= $repeaterGroup['left_col']; ?>
            <div class="text">
                <p class="text-center">
                    E: <a href="mailto:<?php echo $colLeft['email']; ?>"><?php echo $colLeft['email']; ?></a><br />
                    T: <?php echo $colLeft['telefon']; ?>
                </p>
            </div>
        </div>
        <div class="col col2">
            <div style="margin-top: 40px;">
                <?php
                  $args = array(
                    'post_type' => 'html5-blank',
                    'post_status' => 'publish',
                    'posts_per_page' => '100',
                  );
                  $wp_query = new WP_Query( $args );
                  if ( $wp_query->have_posts() ) : ?>
                        <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();
                          // Set variables
                          $title = get_the_title();
                          $description = get_the_content(); 
                          $field = get_field_object('autor');
                          $colors = $field['value'];
                          $date = get_the_date( 'd.m.Y' );
                          // Output
                          ?>
                            <?php // show something ?>
                            <?php $wp_query->reset_postdata(); ?>
                        <?php endwhile; ?>
                    <?php endif; ?>
            </div>
        </div>
        <div class="clear"></div>
    </div>
<?php endwhile; ?>
<?php endif; ?>

1 个答案:

答案 0 :(得分:0)

我发现了问题。我没有重置发布数据,而是不得不重置查询。因此,我更改了行“ $ wp_query-> reset_postdata();”与“ wp_reset_query();”