Manually set global $post vars with an ID, in order to use template tags

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?

4

When your going through your loop add this:

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

//Do something

wp_reset_postdata();

Leave a Comment