Created
July 17, 2015 17:50
-
-
Save brashrebel/f6fa0bdea46ae769f436 to your computer and use it in GitHub Desktop.
The Loop Example
This file contains hidden or 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 | |
// CUSTOM QUERY | |
// Build the arguments for a query | |
$args = array( | |
'author' => 'kyle', | |
'posts_per_page' => 2, | |
'nopaging' => true, | |
); | |
// Create a query object | |
$dis_query = new WP_Query( 'posts_per_page' ); | |
// Proceed if the query actually has something | |
if ( $dis_query->have_posts() ) : | |
// Keep doing this until there are no more entries | |
while ( $dis_query->have_posts() ) : | |
$dis_query->the_post(); | |
the_title(); | |
echo '<br/>'; | |
endwhile; | |
endif; | |
// Here's a query that assumes the MAIN query | |
if ( have_posts() ) : | |
while ( have_posts() ) : | |
the_post(); | |
the_title(); | |
the_content(); | |
endwhile; | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment