Skip to content

Instantly share code, notes, and snippets.

@Ahrengot
Created February 8, 2012 13:47
Show Gist options
  • Save Ahrengot/1769677 to your computer and use it in GitHub Desktop.
Save Ahrengot/1769677 to your computer and use it in GitHub Desktop.
Secondary WordPress loop
// Used for secondary loops. To alter main loops use query_posts() instead.
// Documentation: http://codex.wordpress.org/Function_Reference/get_posts
global $post;
$post_backup = $post;
$myposts = get_posts( array('numberposts' => 5, 'offset'=> 1, 'category' => 1 ));
foreach( $myposts as $post ) {
setup_postdata($post);
the_content();
}
$post = $post_backup;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment