Auto enable embed youtube video with get_post() function

I use get_post() function to get a specific post content. However, I cannot make the auto embed video runs.

Here is the code

Read More
<?php
$post_id = 110;
$queried_post = get_post($post_id);
$content = $queried_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
?>

I want it auto detect the youtube link and enable the embed video.
The sample content is

Check out this cool video:

That was a cool video.

http://codex.wordpress.org/Function_Reference/get_post

http://codex.wordpress.org/Embeds

Related posts

Leave a Reply

1 comment

  1. I haven’t tried this myself, but this is what I can tell you:

    1. The oEmbed functionality is applied in wordpress by a filter.
    2. The get_posts() function suppresses filters by default and I guess get_post() does the same, although I was not able to verify this in the documentation.

    Perhaps you can use query_posts() (which doesn’t suppress filters) or get_posts() with suppress_filters=>false to test this.