Last active
February 21, 2020 06:35
-
-
Save tomjn/6140909 to your computer and use it in GitHub Desktop.
Revisions
-
tomjn revised this gist
Aug 2, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ $pages = new query_loop( array( 'post_type' => 'page' )); foreach( $pages as $id => $post ) { the_title(); // etc... } -
tomjn revised this gist
Aug 2, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,8 @@ // etc... } // put this below in your functions.php: /** * WordPress Main Posts Loop Iterator */ -
tomjn created this gist
Aug 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ <?php $pages = new query_loop( array( 'post_type' => 'page' )); foreach( $posts as $id => $post ) { the_title(); // etc... } /** * WordPress Main Posts Loop Iterator */ class query_loop implements Iterator { public function __construct( $args = array() ) { $this->query = new WP_Query( $args ); } function rewind() { $this->query->rewind_posts(); } function current() { return $this->query->post; } function key() { return $this->query->post->ID; } function next() { $this->query->the_post(); } function valid() { if ( $this->query->have_posts() ) { return true; } else { wp_reset_postdata(); return false; } } }