Skip to content

Instantly share code, notes, and snippets.

@ericmann
Created May 18, 2013 18:18
Show Gist options
  • Save ericmann/5605333 to your computer and use it in GitHub Desktop.
Save ericmann/5605333 to your computer and use it in GitHub Desktop.
<?php
$post_ids = array( 1, 2, 3, 4 );
foreach ( $post_ids as $post_id ) {
$post = get_post( $post_id );
if ( null === $post ) {
continue;
}
setup_postdata( $post );
// ... do stuff with this post
wp_reset_postdata();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment