0

I'd like my embedded tweets to not show a parent/ancestor, for example this is how Wordpress oEmbed displays a single tweet

example embedded tweet

I'd prefer all to look like:

preferred embedded tweet

I tried this approach to filter on oembed_fetch_url with the hide_thread parameter in the Twitter oEmbed api docs

/**
 * Hide threas for all twitter oEmbeds, using the hide_thread=1 query argument
 */
add_filter( 'oembed_fetch_url', function( $provider, $url, $args )
{
    // Target publish.twitter.com provider
    if( 'publish.twitter.com' === parse_url( $provider, PHP_URL_HOST ) )
        $provider = add_query_arg( 'hide_thread', 1, $provider );

    return $provider;
}, 99, 3 );

But it had no effect. I tried also to attach it via CSS on the .EmbeddedTweet-ancestor but you can't touch what's inside the shadowroot.

I'm on an edge of understanding how to work with filtering the ombed html results.

  • I think your code is good, but the oembed is actually in transient so your code isn't in use until the transients disappears, you may have to clear them. – Elex Dec 21 '17 at 6:25
  • Thanks, I think it's working. But it's not the transients, it was the _oembed post_meta that needed clearing e.g. siteorigin.com/clearing-oembed-cache – cogdog Dec 24 '17 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.