2

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.

3
  • 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
    Commented Dec 21, 2017 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
    Commented Dec 24, 2017 at 18:59
  • thanks for the info on this, i have submitted a feature request for Gutenberg oembed blocks, hopefully they consider it wordpress.org/support/topic/…
    – HongPong
    Commented Oct 5, 2020 at 5:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.