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

时间:2013-05-02 09:28:04

标签: php wordpress

我有一个名为'test'的帖子类型。

我想从该帖子类型中呈现特定帖子。

我假设我指定帖子的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; ?>

任何人都有任何想法?任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:2)

对于特定的帖子ID变量是p&amp;不是post_id,试试这个。

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