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!

Comments

15 responses

  1. joey sneddon

    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

      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
    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

      Could you include the error?

      1. craigbradshaw
        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
        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
        craigbradshaw

        Any idea Kraft? See below 😀

        1. Brandon Kraft

          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
            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

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

    1. Brandon Kraft

      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

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

        1. Brandon Kraft

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

          1. Jake

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

Reposts

Leave a Reply

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

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)