Skip to content

Instantly share code, notes, and snippets.

@tanjilahmed7
Created September 13, 2015 10:44
Show Gist options
  • Select an option

  • Save tanjilahmed7/583fec5a9e1e2369039e to your computer and use it in GitHub Desktop.

Select an option

Save tanjilahmed7/583fec5a9e1e2369039e to your computer and use it in GitHub Desktop.
Structure of the Loop
<?php
$args = array(
// Arguments for your query.
);
// Custom query.
$query = new WP_Query( $args );
// Check that we have query results.
if ( $query->have_posts() ) {
// Start looping over the query results.
while ( $query->have_posts() ) {
$query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'left' ); ?>>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php post_thumbnail( 'thumbnail' );?>
</a>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
<?php the_excerpt(); ?>
</article>
<?php
}
}
// Restore original post data.
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment