Dear Melissa,
You are right. Your last code change fixed the problem at me too! Thank you very much!
It didn't work with the previously uploaded contents, but it works with the contents afterwards. I upload contents to this website on every week once. So this is why I needed this delay. It works perfectly with directly and timed publishment as well.
Case is closed on my end. Thank you and have a nice day!