WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How does one get a custom post by id? FYI: I am passing a particular post id through a form and it's performing an ajax call.

I'd like to retrieve just one post and grab the title:

// E.g. $loc = 700
$args = array('post_id'=>$loc, 'post_type'=>'seminars', 'limit'=> '1');

$loop = new WP_Query($args);
// Start loop for seminar posts
echo the_title();

// returns just one post and it's not the right custom post
share|improve this question
up vote 2 down vote accepted

'post_id' is not a valid page/post parameter for WP_Query(). Try using p or post__in instead:

    'p' => 700


    'post__in' => array(
share|improve this answer
+1 Nice information.. – amit Aug 1 '12 at 19:27

If you need only title then why not to use get_the_title function ?

//$post_ID = 700
<?php echo get_the_title($post_ID); ?>

There is NO way we can pass post-ID as parameter to WP_Query() function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.