• Resolved oliverm

    (@oliverm)


    Hi

    We have jetpack in place to post to twitter but it’s posting twitter cards using the “summary” settings and I’d prefer the “photo” setting. It’s also seems to be using random images in the post rather than the featured image.

    Is it possible to change the card type and specify that the featured image is used instead of any other image?

    Olly

    https://www.ads-software.com/plugins/jetpack/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Jetpack automatically sets the Card type depending on your post:

    • If you use the Image Post Format, the Card type will be set to photo and will create a Image meta tag using the Featured Image if it’s large enough (at least 240x240px).
    • If you only inserted one image into your post, and if your post content includes 2 paragraphs of text or less, the Card type will also be set to photo and Jetpack will create an image meta tag using that image.
    • In other cases (if you have more than one image, if your post content includes more than 2 paragraphs, if you don’t use the Image Post Format), the Card type will be set to summary_large_image, summary, or gallery depending on the case.

    If, however, you’d like to overwrite the default Jetpack behaviour and set your own Card Types, you can use the jetpack_open_graph_tags filter, like so:

    function tweakjp_custom_twitter_site( $og_tags ) {
    ????$og_tags['twitter:card'] = 'photo';
    ????return $og_tags;
    }
    add_filter( 'jetpack_open_graph_tags', 'tweakjp_custom_twitter_site', 11 );

    In this example, all posts will start using the photo type, but you’re welcome to add conditionals as you see fit!

    You can place that code in your theme’s functions.php file, or in a functionality plugin.

    I hope this helps.

    Thread Starter oliverm

    (@oliverm)

    Doesn’t appear to be working whatever I do.

    I’ve posted my most recent post as an image post type, I’ve also included that piece of code in my functions.php file of my theme, however twitter STILL shows a summary featuring the first picture on my post which ISNT the featured image.

    The post can be found here:
    https://androidcowboy.com/2014/10/get-better-control-of-your-kids-tablet-with-screen-time/

    And the twitter post for it is here:
    https://twitter.com/AndroidCowboy/status/517621827258945536

    Any ideas why that might be?

    Olly

    Thread Starter oliverm

    (@oliverm)

    In your snippet of code, is there also a way to include the featured image instead of the first image in the post? All our posts always have a featured image.

    Olly

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I had a look at your site, and you seem to be using another plugin to manage Twitter Cards Meta Tags on your site, JM Twitter Cards.

    As long as you use another Twitter Cards plugin, Jetpack automatically disables its own Twitter Cards meta tags to avoid duplicates and conflicts. The code snippet I provided earlier is consequently useless here, since you’re not using Jetpack’s Twitter Cards meta tags at all.

    You’ll consequently need to ask the plugin author if you experience any issues with Twitter Cards. fwiw the Card seems to work properly on my end: the image is displayed nicely:
    https://i.wpne.ws/XqJr

    Another solution would be to delete the JM Twitter Cards plugin and let Jetpack handle the tags for you. The code snippet I mentioned earlier will then be used.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Jetpack and twitter card types and featured image’ is closed to new replies.