How to query post by post id

Hi guys,
I want to show a specific wordpress post in a modal popup. I’ve retrieve the post id via ajax, but when I query for the post with the code bellow it throws error:


query_posts(array(
	'post__in' => $post_id
));
if ( have_posts() ) :
	while ( have_posts() ) : the_post();
		the_content();
	endwhile;
endif;

My Google search suggests that I should do the query this way. But why it isn’t working?

Thank you,

Is post__in supposed to have 2 underscores?
What is the error message?

Thank you,
I got it. It should be:


query_posts(array(
	'post__in' => array($post_id)
));
if ( have_posts() ) :
	while ( have_posts() ) : the_post();
		the_content();
	endwhile;
endif;

Instead of doing that, use get_post(). Using query_posts() like that is a bad idea and can cause unwanted side effects (because it will change your main WordPress query for that particular page & you need to remember to reset it by calling wp_reset_query() after your block of code). Which is why it is better to use get_post() for a single post (where you know post ID) & get_posts() for multiple posts.

Hi guy, I’ve found this plugin: Content Views http://wordpress.org/plugins/content-views-query-and-display-post-page/
It is easy to query post(s) by id, without coding!
It even offers you more features.