1
我正在研究page,我正在使用CPT来显示我的帖子。第二篇文章后,我想添加一个图像,并在四个以上的帖子后,我想添加另一个图像。WordPress - 如何使用ACF的中继器在每x后发布图像后输出图像
在ACF中,我设置了一个中继器,但我不确定如何执行它,以便知道何时显示图像(位于第二个文章后面),然后位于四个以上的文章之后。
这里是我的循环:
function management_team_query() {
$args = array(
'posts_per_page' => -1,
'post_type' => 'management-team',
'order' => 'ASC',
);
$team_query = new WP_Query($args);
if ($team_query->have_posts()) :
$html_out = '<article class="team-member box-center">';
while ($team_query->have_posts()) :
$team_query->the_post();
$role = get_field("role");
$name = get_field("team_member_name");
$bio = get_field("bio");
// $profile = get_the_post_thumbnail_url($post->ID, 'full' );
$flip = get_field("flip_content");
// Do stuff with each post here
$html_out .=
'<div class="meta-team box vc_col-sm-5 vc_col-lg-offset-1">
<div class="flip-container" ontouchstart="this.classList.toggle("hover");">
<div class="flipper">
<div class="front">
<h6>' . $role . '</h6>' . '<h4>' . $name . '</h4>' . $bio . '
</div>
<div class="back">
Lorem Ipsum
</div>
</div>
</div>
</div>';
endwhile;
$html_out .= '</article>';
else : // No results
$html_out = "No News Found.";
endif;
wp_reset_query();
return $html_out;
}
我提供了一个链接到我工作的例子,这里有一个什么,我希望它是什么样子,check it out。
最好是使用PHP来做一些计数?我喜欢ACF的想法,因为其他人可以更轻松地管理自定义字段中的照片。
但如果是两个不同的图像我可以用 “或”?就像在该地区做acf的东西,我称之为自定义领域,它是如何不重复这两个计数? –
这些操作符可以全部改为公平的,==为===,因为php在两者之间存在一些奇怪的差异,因为这是标准做法,人们会生气。 – samisonline
我不确定我是否理解,与帖子本身有关的ACF字段? – samisonline