Use Auto Embed with get_post()
You need to set the global $post object to your post. This is done by the loop functions in your theme which is why it works there. WP’s oEmbed replaces the URLs during the the_content filter. But it replaces the URLs through two means. The first is a simple regex find and replace for certain … Read more