我正在尝试使用Wordpress和Advanced Custom Fields(ACF)制作一个“相关”模块。
我有以下循环:
<?php
// Settings
$categories = get_the_category();
if ( count($categories) < 2 ) {
$cat = $categories[0]->cat_ID;
} else {
$cat = $categories[1]->cat_ID;
}
$query = new WP_Query('cat='. $cat);
?>
<section class="related">
<?php // The loop
if ($query->have_posts()):
while ($query->have_posts()) : $query->the_post();
// The content part
if (have_rows('content')):
while (have_rows('content')) : the_row();
// Only print cover
if (get_row_layout() === 'cover'):
// Cover content...
endif;
// End: The content part
endwhile;
endif;
// End: The loop
endwhile;
// Reset loop, keep Wordpress from looping through unwanted modules
wp_reset_postdata();
endif;
?>
</section>
我希望循环只打印封面模块,而是打印 content -module中的所有字段,这是灵活内容字段< / em>的。我是否监督某些事情导致它将其他模块与 cover 分开?
答案 0 :(得分:0)
通过拉出// The content part