Jetpack’s Publicize Now Uses Twitter Cards

A long time ago, Jetpack’s Publicize featureโ€”which automatically posts to your social media platforms when you publish a new postโ€”started attaching an image to your tweets to help them catch people’s attention.

At the time, a tweet with a picture would perform better than a tweet with just a link.

This is all fine and good, but a lot has changed since Jetpack started doing that. Twitter cards, if nothing else, not only were developed but were opened up to all (remember when you used to have to opt-in?). When you attach media, that’s the “special” part of your tweet. The Twitter Card, rendered from the meta tags on your post, is not displayed.

Today, effective for all versions of Jetpack and all WordPress.com sites, Publicize will no longer attach a picture to your tweet, instead allowing Twitter to display the Twitter card it renders.

If you want to return to the old way and are on Jetpack 8.5 (released today) or WordPress.com Business, you can add a small code snippet to change it.

add_filter( 'jetpack_publicize_options', function( $option ) { 
    $option['attach_media'] = true;
    return $option;
} );

This filter will, in the end, notify WordPress.com’s server of your preference and use it for future Publicize posts.

Questions about Jetpack’s Publicize feature? There is a team of Happiness Engineers ready to help!



Posted

in

Comments

16 responses to “Jetpack’s Publicize Now Uses Twitter Cards

  1. joey sneddon Avatar

    Sadly adding the snippet to functions.php (or running it in a code snippet tool) has no effect. Images are not attached to tweets.

    1. Brandon Kraft Avatar

      Thanks for pointing that out! There was a typo in the snippet. jetpack_publicize_option should have been jetpack_publicize_options.

      The post has been updated. Thanks for pointing it out!

  2. craigbradshaw Avatar
    craigbradshaw

    Hey, I’m just throwing this out there – I threw this PHP in and I’m getting an error (I amended the typo) – Publicize is still just resolving an image itself.

    1. Brandon Kraft Avatar

      Could you include the error?

      1. craigbradshaw Avatar
        craigbradshaw

        Weirdly, I did reply this morning but it didn’t post, and now it’s no longer on my clipboard…I’ll trynand find it again but it did moan about functions.php.

      2. craigbradshaw Avatar
        craigbradshaw

        hey Brandon, right, here’s the output/error : Warning: count(): Parameter must be an array or an object that implements Countable in /home/*****/public_html/wp-includes/post-template.php on line 317

        Warning: Cannot modify header information – headers already sent by (output started at /home/*****/public_html/wp-includes/post-template.php:317) in /home/*****/public_html/wp-admin/post.php on line 231

      3. craigbradshaw Avatar
        craigbradshaw

        Any idea Kraft? See below ๐Ÿ˜€

        1. Brandon Kraft Avatar

          Hi Craig, in and of itself, I don’t see how it’s related to the change Jetpack made nor the code snippet above.

          My guess is a plugin or theme is needing an update to be more compatible with newer versions of PHP.

          1. craigbradshaw Avatar
            craigbradshaw

            OK Kraft – thanks for the update

  3. […] the tweets directly in the WordPress editor. As a prerequisite, last month’s release of Jetpack 8.5 introduced support for Twitter cards, which increase the click rate of the resulting tweets. This […]

  4. Jake Avatar

    Question: To which file do we add that code snippet? Thanks!

    1. Brandon Kraft Avatar

      Hi Jake,

      You have a few options. You can use something like a Code Snippets plugin or a Core Functionality plugin of your own making.

      The key is you definitely don’t want to add it to an existing plugin that you’ve installed on your site from the WordPress plugin directory or a theme, particular one that has updates possible (like any from the WordPress directory). In both of those cases, the snippet would be lost when the plugin/theme is updated.

      1. Jake Avatar

        Awesome, thanks. I already had Code Snippets installed. Should I set it to run everywhere or just in admin area?

        1. Brandon Kraft Avatar

          Everywhere would be best. There are instances where we’d check that value outside the admin area.

          1. Jake Avatar

            It works! Thank you so much for all your help!

Leave a Reply