Skip to content

Instantly share code, notes, and snippets.

@gmazzap
Forked from tomjn/loop.php
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmazzap/77d7b4f6f7ce06fb56cc to your computer and use it in GitHub Desktop.
Save gmazzap/77d7b4f6f7ce06fb56cc to your computer and use it in GitHub Desktop.
<?php
array_walk($GLOBALS['wp_query']->posts, function($post, $i, $wp_query) {
$GLOBALS['post'] = $post;
$wp_query->the_post();
// loop code
the_title();
the_content();
$wp_query->have_posts(); // this will fire 'loop_end' when needed
}, $GLOBALS['wp_query']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment