Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a function retrieving ID's of posts by very specific means.

I need to be able to set the global $post in order to use functions like the_content(), which does not allow an ID as a parameter.

How can I achieve this?

share|improve this question
1  
What exactly do you mean with "set the global $post"? Could you please a) post the function retrieving the IDs and illustrate/sketch your use case? –  kaiser Oct 10 '11 at 13:21
add comment

2 Answers

When your going through your loop add this:

global $post; 
$post = get_post( $ID, OBJECT );
setup_postdata( $post );

//Do something

wp_reset_postdata();
share|improve this answer
add comment

To work with posts outta loop try using:

get_post(post_id)

to get a post with a specific ID out of the loop,when you do this,the global object $post will hold the post which you'v just selected.Now you can get the content using :

$post->post_content .

check the get_post documentation on Wordpress Codex

share|improve this answer
add comment

Your Answer

 
discard

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.