That’s what I gave you a short example of. You need to substitute calling functions that allow supplying the current post ID rather than depending on setup_post_data()
to populate $post.
The examples on this site are set up assuming that the main WP query is what your using and not a nested query. They are not good examples if you have queries nested to the 3rd level or more running, which is basically what you have going here.