• I have a fresh WordPress install and am using Twenty Thirteen. I have added the following to the functions file

    add_filter( 'embed_oembed_html', 'tdd_oembed_filter', 10, 4 ) ;
    function tdd_oembed_filter($html, $url, $attr, $post_ID) {
        $return = '<figure class="video-container">'.$html.'</figure>';
        return $return;
    }

    but it’s not working. My YouTube videos aren’t surrounded by <figure class=”video-container”></figure>. I’ve tried various variations of the filter and function code I’ve found through Google search and none of them work for me.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The code works well, you just need to use the link from the video, not the iframe version. I mean, just add, for example:

    https://www.youtube.com/watch?youTubeVideo

    And it will be wrapped with the container defined in your filter function.

    As per the WordPress oEmbed instructions here, the ’embed_oembed_html’ should work when using the [embed] shortcode as well, but it does not.

    I’m having the same issue.

    Must be a bug.

    I take that back.
    Looks like JetPack’s “Shortcode Embeds” overrides the ’embed_oembed_html’ filter.

    You’ll need to deactivate the “Shortcode Embeds” module to use your own filter.

    @WalletStation

    Try changing your code to this:

    add_filter( ’embed_oembed_html’, ‘tdd_oembed_filter’, 99, 4 ) ;
    function tdd_oembed_filter($html, $url, $attr, $post_ID) {
    return = ‘<figure class=”video-container”>’.$html.'</figure>’;
    }

    Also, where are you dropping the code?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘embed_oembed_html filter doesn't work’ is closed to new replies.