Skip to content

Instantly share code, notes, and snippets.

@dmtintner
Created June 24, 2012 18:18
Show Gist options
  • Save dmtintner/2984291 to your computer and use it in GitHub Desktop.
Save dmtintner/2984291 to your computer and use it in GitHub Desktop.
Perfect wp_query usage
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="faculty-post">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
</div><!-- closes .faculty-post -->
<div class="clear"></div>
<?php endwhile;
} //faculty post loop ends?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment