Embeding YouTube video via a template function throws iframe cross-domain policy error

Building a fake embed shortcode and then calling run_shortcode to do this makes no real sense. Try this instead:

echo $wp_embed->shortcode(array(), $my_tour_video);

Edit: Additionally, when I use your code on a test page, using that embed, I get no such error as you’re describing. If you can come up with a reproducible test case, then it might be solvable.

If you are using the /embed/ URL, then that might cause it. Use the real URL of the video instead, as it shows when you’re looking at YouTube’s video page. The same URL you would normally paste into a post’s content.

tech