https://joseph-dickson.com/presentation/wp-query-the-loop
Use your arrow keys or swipe to navigate this slideshow
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
// Post Content here
} // end while
} // end if
?>
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
echo 'no posts found.';
}
/* Restore original Post Data */
wp_reset_postdata();
// The Query
$the_query = new WP_Query( $args );
$the_query = new WP_Query(
array('post_type' => 'page' )
);
// The Query
$the_query = new WP_Query( $args );
$the_query = new WP_Query(
array('post_type' => 'attachment' )
);
// The Query
$the_query = new WP_Query( $args );
$the_query = new WP_Query(
array(
'post_type' => 'attachment',
'post_mime_type' => 'application/pdf',
'posts_per_page' => '-1,
)
);
// The Query
$the_query = new WP_Query( $args );
https://joseph-dickson.com/presentation/wp-query-the-loop