My custom post type name is movie_reviews. Inside movie reviews there are multiple post but i need only that post whose id is 244. My code for it is

<?php
    $my_query = new WP_Query('post_type=movie_reviews&ID=244');
      while ($my_query->have_posts()) : $my_query->the_post(); 

    the_content();
endwhile ?>

2 Answers
2

Have a look at the Post & Page Parameters Section in the WP_Query Documentation

For getting a Post by Post ID, you need to use this:

$my_query = new WP_Query('post_type=movie_reviews&p=244');

If you only need the content of one specific post, you can also do this:

$mypost = get_post(244);
echo apply_filters('the_content',$mypost->post_content);

In this case, you don’t need to worry about the loop or the global vars getting overwritten, removing your main loop.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *