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

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

问题描述:

I have a post-type called 'test'.

I'd like to render a specific post from that post-type.

I'm assuming I specify the post's ID to do that.

After some Googling this where I've ended up, but it shows all the posts, not just the Post with an ID of 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; ?>

Anyone have any idea? Any help would be greatly appreciated. Thanks!

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

我' 我希望从那个帖子类型中呈现一个特定的帖子。 p>

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

之后 谷歌搜索我已经结束的地方,但它显示了所有的帖子,而不仅仅是ID为1的帖子。 p>

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

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

For specific post Id variable is p & not post_id, Try this.

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