Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save esedic/9e4aea458530a530e09ef5c649e51d08 to your computer and use it in GitHub Desktop.
Save esedic/9e4aea458530a530e09ef5c649e51d08 to your computer and use it in GitHub Desktop.
A standard WP_Query loop
<?php
$args = [
// parameters go here
];
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// display the post
the_title();
the_content();
}
wp_reset_postdata();
} else {
echo "no posts were found";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment