Last active
February 21, 2021 00:44
-
-
Save jasondevine/1d9c9c9bd5c4cbdb58ebb7fc10e4a19a to your computer and use it in GitHub Desktop.
Here's a basic skeleton for a loop called using the WP_Query class. You could use this to display a secondary loop on the homepage, for example, a block featuring specific categories.
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 | |
$args = array( | |
// arguments for your query | |
); | |
// the query | |
$query = new WP_Query( $args ); | |
// The Loop | |
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post() ; | |
// contents of the Loop go here | |
endwhile; endif; | |
/* 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