How to Hide Ancestors/Threads in Embedded Tweets

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.

0

Leave a Comment