Php 循环浏览ACF内容
我试图用Wordpress和(ACF)制作一个“相关”模块 我有以下循环:Php 循环浏览ACF内容,php,wordpress,loops,advanced-custom-fields,Php,Wordpress,Loops,Advanced Custom Fields,我试图用Wordpress和(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_Que
<?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>
我希望循环只打印封面模块,而不是打印内容模块内的所有字段,这是一个灵活的内容字段。我是否在监督导致它在封面之外循环其他模块的东西?通过将while循环拉出
//内容部分通过将while循环拉出//内容部分