EUREKA! John, you are a genius. I think if I had just removed the global $post in the very beginning it would have worked fine – when I put the code back to the way it was before (and exactly as you suggested) and removed global $post, it is working perfectly.
Thank you a huge amount! If this forum had the emoji for a hug, I would include it here. 🙂