我在获取以下代码时遇到问题。我创建了一个高级自定义字段(top\\u articles),其中有一个复选框,包含三个选项:top\\u articles\\u left、top\\u middle、top\\u articles\\u right。我会这样做,当你在一个帖子中时,你可以检查一下你想要该帖子的特色,然后它会出现在我指定的三个区域中。我怎样才能用ACF做到这一点,并让它在WordPress中找到正确的帖子?
<section class="top-articles">
<h2>Top Articles</h2>
<?php $articles_query = new WP_Query(\'category_name=main&posts_per_page=1\');
while ($articles_query->have_posts()) : $articles_query->the_post(); ?>
<?php if (get_field(\'top_articles\') == \'top_articles_left\'): ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(\'large\'); ?>
</a>
</article>
<?php endif; endwhile; ?>
<?php $articles_query = new WP_Query(\'category_name=main&posts_per_page=1\');
while ($articles_query->have_posts()) : $articles_query->the_post(); ?>
<?php if (get_field(\'top_articles\') == \'top_articles_middle\'): ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(\'large\'); ?>
</a>
</article>
<?php endif; endwhile; ?>
<?php $articles_query = new WP_Query(\'category_name=main&posts_per_page=1\');
while ($articles_query->have_posts()) : $articles_query->the_post(); ?>
<?php if (get_field(\'top_articles\') == \'top_articles_right\'): ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(\'large\'); ?>
</a>
</article>
<?php endif; endwhile; ?>
</section>