xxxxxxxxxx
have_posts(): check if there are more posts in a queue. That's why it is mostly
placed in if-else or while condition e.g. if (have_posts()). it works by checking
posts at WP_Query object to loop over
the_post(): basically sets the current post, and checks whether the loop has
started hence, it also helps to keep moving to the next post
xxxxxxxxxx
if ( have_posts() ) {
while ( have_posts() ) {
the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php }
}