Skip to content

Instantly share code, notes, and snippets.

@kylelarkin
Created April 28, 2015 19:34
Show Gist options
  • Save kylelarkin/52d704a7688e32275945 to your computer and use it in GitHub Desktop.
Save kylelarkin/52d704a7688e32275945 to your computer and use it in GitHub Desktop.
Custom WordPress Query
<?php
// Setup the Arguments for the Custom Query
$args = array(
'post_type' => ''
);
// Create the Custom Query and save it as a variable
$the_query = new WP_Query( $args );
// Loop through our Custom Query results
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<!-- Output Goes here -->
<?php endwhile;
// If we didn't find anything, let us know
else :
echo '<p>No quotes were found.</p>';
endif;
// Rest the data so we don't break the default loop
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment