显示特定post类型的特定post-id


Show specific post-id from a specific post-type

我有一个post类型test

我想从post-type中渲染一个特定的post。

我假设我指定了帖子的ID来做到这一点。

在谷歌上搜索了一下之后,我找到了这个,但它显示了所有的帖子,而不仅仅是ID为1的帖子。

<?php $loop = new WP_Query( array('post_id' => 1, 'post_type' => 'test', 'posts_per_page' => 10) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
     <?php the_content(); ?>
 <?php endwhile; ?>

有人知道吗?任何帮助都将非常感激。谢谢!

对于特定的post Id变量为p &不是post_id,试试这个

$loop = new WP_Query( array('p' => 1, 'post_type' => 'test', 'posts_per_page' => 10) );