Skip to content

Instantly share code, notes, and snippets.

@ibrokemywp
Created November 22, 2014 11:00
Show Gist options
  • Save ibrokemywp/c106d7b7e890d4180a13 to your computer and use it in GitHub Desktop.
Save ibrokemywp/c106d7b7e890d4180a13 to your computer and use it in GitHub Desktop.
Reset the loop after you've hijacked it
/**
* Go ahead. Do your fancy shit
*/
$your_query = new WP_query( 'post_type' => 'your_cool_post_type' );
while( $your_query->have_posts() ) {
$your_query->the_post();
/**
* Look at your cool template function.
* That looks just like my template function.
* Oh, that's because it is. Now my page's
* the_title() is your post's the_title().
*/
the_title();
}
/**
* You can give me back my the_title() like this.
*/
wp_reset_query();
/**
* Thanks dude.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment