Skip to content

Instantly share code, notes, and snippets.

@verticalgrain
Last active August 29, 2015 14:10
Show Gist options
  • Save verticalgrain/e027063e841616bdf845 to your computer and use it in GitHub Desktop.
Save verticalgrain/e027063e841616bdf845 to your computer and use it in GitHub Desktop.
Basic Wordpress Loop - using WP_Query
<?php
// Query arguments go here - for all query arguments see: http://goo.gl/GuIvSn
$args = array(
//'numberposts' => -1,
//'post_type' => 'event',
//'meta_key' => 'location',
//'meta_value' => 'Melbourne'
);
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<!-- Put all your dynamic content here -->
<?php the_title(); ?>
<?php the_content(); ?>
<?php //the_field('test_field'); // Advanced custom field ?>
<!-- End dynamic content -->
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); // resets query - important if multiple queries on one page ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment