高级自定义字段重复器,帖子对象不重复内容
我正在尝试使用内部带有 post 对象的转发器,如下所示:
它仅显示两个代表中的一个:
这是我的代码是用于尝试完成此操作:
<?php
$args = array(
'post_type' => 'find-your-rep',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$loop = new WP_Query( $args );
$i = 0;
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); $i++ ?>
<span id="div<?php echo $i ?>" class="targetDiv">
<div class="repCard">
<?php if ( have_rows( 'reps' ) ) : ?>
<?php while ( have_rows( 'reps' ) ) : the_row(); ?>
<h3><?php the_sub_field( 'location' ); ?></h3>
<?php $rep = get_sub_field( 'rep' ); ?>
<?php if ( $rep ) : ?>
<?php $post = $rep; ?>
<?php setup_postdata( $post ); ?>
<div class="fullname"><?php the_title() ?></div>
<?php if ( get_field( 'company' ) ) : ?><div class="company">
<?php the_field( 'company' ); ?></div>
<?php endif; ?>
<?php if ( get_field( 'phone' ) ) : ?>
<div class="phone"><i class="phone icon"></i>
<a href="tel:<?php the_field( 'phone' ); ?>">
<?php the_field( 'phone' ); ?></a>.
</div>.
<?php endif; ?>
<?php if ( get_field( 'email' ) ) : ?>
<div class="email">
<i class="envelope icon"></i> <a href="mailto:<?php the_field( 'email' ); ?>">
<?php the_field( 'email' ); ?></a></div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
Sorry, there's no rep assigned to this location.
<?php endif; ?>
</div>
</span>
<?php endwhile; wp_reset_postdata(); ?>
我很感激任何帮助/指示来解决此问题。
I am attempting to use a repeater with a post object inside as seen here:
Picture of ACF repeater with post object
It is only showing one out of two Reps:
Here is the code I am using to attempt to accomplish this:
<?php
$args = array(
'post_type' => 'find-your-rep',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$loop = new WP_Query( $args );
$i = 0;
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); $i++ ?>
<span id="div<?php echo $i ?>" class="targetDiv">
<div class="repCard">
<?php if ( have_rows( 'reps' ) ) : ?>
<?php while ( have_rows( 'reps' ) ) : the_row(); ?>
<h3><?php the_sub_field( 'location' ); ?></h3>
<?php $rep = get_sub_field( 'rep' ); ?>
<?php if ( $rep ) : ?>
<?php $post = $rep; ?>
<?php setup_postdata( $post ); ?>
<div class="fullname"><?php the_title() ?></div>
<?php if ( get_field( 'company' ) ) : ?><div class="company">
<?php the_field( 'company' ); ?></div>
<?php endif; ?>
<?php if ( get_field( 'phone' ) ) : ?>
<div class="phone"><i class="phone icon"></i>
<a href="tel:<?php the_field( 'phone' ); ?>">
<?php the_field( 'phone' ); ?></a>.
</div>.
<?php endif; ?>
<?php if ( get_field( 'email' ) ) : ?>
<div class="email">
<i class="envelope icon"></i> <a href="mailto:<?php the_field( 'email' ); ?>">
<?php the_field( 'email' ); ?></a></div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
Sorry, there's no rep assigned to this location.
<?php endif; ?>
</div>
</span>
<?php endwhile; wp_reset_postdata(); ?>
I'd appreciate any help/direction to resolve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论