The global
variable $post
will be set to the first post in the main query. When any Loop runs (assuming it is constructed correctly), whether the main Loop or any number of secondary ones, $post
will be set to each post in that/those loops in turn. At the end of the Loop, it will be set to the the last post in the last Loop that ran. The functions wp_reset_query
and wp_rest_postdata
help clear this up in a lot of cases.
I am pretty sure that the problem is the construction of your “loop inside of a loop” but you don’t post the code so guessing is all I can do. My guess is that you have something like:
$recent = get_posts(/*...*/);
foreach ($recent as $r) {
the_title();
}
And you need:
$recent = new WP_Query(/*...*/);
if ($recent->have_posts()) {
while($recent->have_posts()) {
$recent->the_post();
the_title();
}
}
wp_reset_postdata();