我知道您想要“使用WP\\u查询”的解决方案,但为什么不使用get_posts()
为了这个?
$posts_ids = get_posts(\'post_type=post&posts_per_page=-1&fields=ids\');
// $posts_ids is now an array of IDs
echo implode(\',\', $posts_ids); // prints: 123, 124, 125, 126, ...
// or
foreach( $posts_ids as $id ) {
echo $id;
}