Skip to content

من النهر إلى البحر
#FreePalestine

Twitter’s WordPress Plugin Fix

Twitter’s WordPress plugin fix is necessary as the outdated plugin is handicapping Twitter’s Card output. There is no option to customise the meta tags or even disable it, and it may even overwrite other SEO plugins’ output.

Since it injects the tags later in the <HEAD> section, it overrides the meta tags by my SEO plugin. This would render the image in the link preview into a tiny image.

A screenshot of a link preview, with a small image preview, in Telegram app.
Annoyingly small.
<meta name="twitter:card" content="summary">

instead of how I want it, like so.

<meta name="twitter:card" content="summary_large_image">
A screenshot of a link preview, with a large image preview, in Telegram app.
How I want it to be.

I’ve managed to ‘fix’ it by commenting the injected codes in the MetaElement.php file.

return '<!--<meta name="' . esc_attr( self::PREFIX . $name ) . '" content="' . esc_attr( (string) $content ) . '"' . \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '>-->';

Another method of Twitter’s WordPress plugin fix is to edit the twitter.php file and insert these lines, but I opted to comment out the meta tags altogether instead. It’s cleaner, and it would avoid duplicates of the meta tags, thus avoiding conflicts between plugins.

function twitter_card_type( $card_type, $query_type, $object_id )
{
  return 'summary_large_image';
}
add_filter('twitter_card_type', 'twitter_card_type', 10, 3);

Update (August 2023)

This Twitter’s WordPress plugin fix is unnecessary now as I’ve disabled it. Twitter’s profile embed has stopped working, and when Space Karen re-enabled it, it wasn’t working like before. The singular reason for my having this plugin is because it allows customisation of a Twitter timeline. Currently, a Twitter profile embed will show a L-O-O-N-N-N-G-G-G-G list of the user’s tweets.

Published inSoftwareWordPress

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *