Your inner loop overwrites the contents of $post
, so any later template tags use the values of whatever it last contained.
“But I used wp_reset_postdata()
!” you say? What that function does is try to restore $post
from $wp_query->post
. It’s meant to restore the main query after secondary queries. You have two secondary queries here, so that method fails.
To fix it- either use $wp_query
as a new WP_Query
instance for your outer loop, which will result in wp_reset_postdata()
working as expected, or assign your outer post to some other variable name and don’t use template tags that rely on the global $post
.