我正在尝试按用户 ID 查询帖子。在这种情况下,用户 id 将是另一篇文章的作者。
我确实尝试了以下方法,但是没有得到“作者论点”。
$author_id = $post->post_author;
$author_query_id = array('author='. $author_id, 'showposts' => '1', 'post_type'=> 'bedrijven', 'post_status' => 'any');
$author_posts_id = new WP_Query($author_query_id);
while($author_posts_id->have_posts()) : $author_posts_id->the_post();
if (get_field('standplaats')) { ?>
<div class="fieldje field-3"><p>
<span>Standplaats: <?php echo the_field('standplaats'); ?></span>
</p></div>
<?php }
endwhile;
我得到的用户 ID 是正确的(在 $author_id 中捕获)。然而,在查询中,它只查询帖子类型“Bedrijven”的最后一篇帖子,无论作者是谁。
知道为什么这不起作用吗?
谢谢!