Last active
August 29, 2015 14:10
-
-
Save verticalgrain/e027063e841616bdf845 to your computer and use it in GitHub Desktop.
Basic Wordpress Loop - using WP_Query
This file contains 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 characters
<?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