<?php
while(have_posts()) {
the_post();?>
<h2><a href=”<?php the_permalink()?> “><?php the_title();?></a></h2>
<?php the_content(); ?>
<hr>
<?php }
?>
What do have have\_posts() and the\_post() actually do? I get that have\_posts returns a boolean, but is the context different depending on whether The Loop is in an index, single, or page file? So for index I guess it finds the blog posts in the database, but for page the\_post will just select all the content the user inputted in the admin panel?
the\_post is essentially iterating over all the posts in database while at the same time selecting the most recent one? Is that how it works?
[ad_2]
[https://developer.wordpress.org/reference/functions/have_posts/])
It works off of the global $wp_query, which is, as the name implies, an instance of wp_query:
[https://developer.wordpress.org/reference/classes/wp_query/])
The loop in general is explained a bit here:
[https://developer.wordpress.org/themes/basics/the-loop/])