New plugin : JM Twitter Cards

Adding Twitter cards to WordPress can be tricky. My plugin allows you to choose what type of card (photo, summary) you want to integrate and customize your card for each posts.

How does it work?

Go to settings > JM Twitter Cards and configure the plugin to your needs.

Options :

There are all options you need to add Twitter card (photo and summary) whether they’re required or optional:

  1. type of card : summary, photo? if you choose photo you can set optional settings.
  2. your Twitter account (creator) : you or the author
  3. la description : it is required but in most of the tutorial codes call get_the_excerpt()  outside the loop ! This can’t work ! Fortunately my plugin is using another function that returns the_excerpt according to a number of words you can set. If you choose 34 it will return the first 34 words of your post.
  4. image URL : really important ! Imagine your post doesn’t have any thumbnail, you can set a default image (give a URL).

Once config is done, it will output this in your page markup (<head>):





@your_site_twitter_account"/>
@your_twitter_account"/>

If you do not this it won’t work !

I added links to validate your card. If you do not submit your website to Twitter it won’t work. Actually Twitter has to approve your site. It’s a special feature.

Download

Here is the URL to download the plugin

14 thoughts on “New plugin : JM Twitter Cards

  1. I have different pages on my site. Some of them is okay to have the twitter card summary, but in others I want the option to make those pages as twitter card photo. It looks like the settings apply to all the pages and post on the site. Any flexibility to be able to change the options per page or post? Thanks and God bless

    1. Hi Chr1stlike, glad you use my plugin. For now the plugin add Twitter Card Markup only on posts because it’s basically the most common use. What you’re asking for might take a long time because there are a lot of changes to make.

      I see what I can do so grab the RSS to stay stuned.
      Regards.

  2. Salut!

    I have a couple of problems that I hope can be resolved. Here they are:

    Problem #1

    I installed JM Twitter Card plugin yesterday and everything seemed fine on “view source mode.” In other words, title, description, website for the Twitter Card application were/are all listed there.

    Yet, whenever I tested the Twitter preview yesterday, I got a message saying that neither title nor description could be found.

    “Missing Tag: twitter:title
    Missing Tag: twitter:description”

    That remains a problem for all posts published *before* I installed the plugin.

    Problem #2

    I’ve just retested a couple of posts — both published *after* I installed the plugin — and for those two I’m getting a *different* error message:

    “Pre-fetching image /http://www.altfg.com/blog/wp-content/uploads/2013/01/barbra-streisand-james-brolin.jpg failed because it’s denied by robots.txt.”

    I’ve just now (temporarily) deleted the “disallow” command from the site’s robots.txt file. So far, it hasn’t made any difference; I’m still getting the same error message. I’m assuming it’ll take a while for Twitter to update its cached robots.txt file.

    But now I have a different question/issue:

    The site’s images are uploaded both via wp-uploads and directly to the server via FTP. Those uploaded via FTP are located in a different folder on the server, apart from WordPress. These images are also the ones actually found in the posts.

    Is there a way to “force” the plugin to use *those* images found in the “Stars” folder?

    Please check out this url:

    /http://www.altfg.com/blog/movie/barbra-streisand-oscar-2013-singer/

    And here’s the uploaded image found in the post:

    /http://www.altfg.com/Stars/film-movies/barbra-streisand-james-brolin.jpg

    Now, why do we also upload images via wp-uploads? Because that’s the only way we can get thumbnails to work. Those images/thumbnails are NOT found in the posts themselves, but only on the homepage and follow-up pages, and in the “related thumbnails” plugin that we use.

    Any assistance / suggestions would be *much* appreciated.

  3. In case you’re wondering why we’ve been uploading images via file transfer protocol… I created that site a few years ago; it was a personal site then, and I didn’t use a blog platform. Began doing so only about three years later & WordPress wasn’t as sophisticated (when it comes to image uploading/storing) as it is now.

    FTP was the way to upload images…

    Regards.

  4. Hi Andre, I’ve been running some tests and I can ensure your issue is not due to my plugin. Code is fine. But that does not solve any problem.
    #1
    So here is a thing : You do not have to modify robots.txt you just have to add some rules for Twitter :

    User-agent: Twitterbot
          Disallow: *
     
          Allow: /wp-content/uploads/
    

    Besides your crawl-delay might be another problem.

    #2
    I’m afraid this can’t be undone. My plugin is looking for a featured image (“post_thumbnail”), if nothing is found it will take the default image you can set in option page.

  5. Merci, Julien.

    Should I add that code at the top of the robots.txt file?

    Quick question: Why would the site’s crawl-delay be problem? How could I fix that?

    And finally …

    What about problem #1?
    Why am getting this error message for posts published before I installed JM Twitter Card plugin?

    “Missing Tag: twitter:title
    Missing Tag: twitter:description”

    Once again, any assistance would be much appreciated.
    Merci.

    1. You’re welcome :) You can add code I gave after.
      #1, I don’t know the very-reason for that because when I look into source code, markup is there. Maybe Twitter crawls your site… slowly.
      Are Cards activated on your domain? Did you receive mail confirmation ? It’s mandatory.

      Edit: Sorry I missed your question regarding crawl-delay. It is set to 30 but correct values are 1 (slow), 5 (very slow) and 10 (very very very slow). I’m not a SEO expert but the only thing can happen with such a rule is to limit visit from bots. So… maybe you can delete it.

  6. Merci, Julien.
    No, I’m getting the error message in the Twitter preview tool. I don’t get it. I’ve posted a question about that on the Twitter forum.
    And I can’t apply to have the card activated unless it’s working… So, it’s a Catch-22 sorta situation…

  7. Great plug-in Julien! Merci beaucoup!

    I’m completely new to WordPress, so please bear with me if I come across as such ;-)

    I have installed your plug-in in the hopes of showing a vimeo video of my book trailer and I previewed the twitter card on:

    https://dev.twitter.com/docs/cards/preview

    and added the HTML Meta tags:

    and I hit the Preview Card button and the preview keeps defaulting to the fallback image.

    Any ideas on what I could be doing wrong?

    Is this not possible until I get approval from Twitter?

    Thank you so much in advance!

    1. Hi Tony,
      Welcome to WordPress and Welcome to this blog. :)
      This is normal. My plugin checks if there’s a featured image (post thumbnail) and if not it displays the fallback. So your post has to have a featured image and this image will be shown on your card.

  8. Hi Julien,

    I would write in French if I could.. ;)
    I really like this plugin but I have some questions and suggestions:
    Please read them here:
    http://wordpress.org/support/topic/feature-request-use-embedded-pictures-as-twitterimage
    http://wordpress.org/support/topic/conflict-with-plugin-simply-exclude
    http://wordpress.org/support/topic/suggestion-better-place-to-store-authors-twitter-name

    It would be awesome if you could answer all of them!

    Thank you very much in advance!
    Philipp

  9. Thank you for this plugin – it works quite well. But I am trying to figure out how to make one thing happen: I would like to use my excerpt as the twitter:description.

    This is important because All my posts have excerpts, not all have SEO descriptions.

    Is there a way to do this?

    Thank you!

    1. Hi Jeff,

      In the latest version of the plugin you can set this in option page. You can disable content from SEO plugin and keep excerpt. This excerpt can be set according to the words count you choose. Remember that you can set 70 words at most. Hope this is the answer you look for. :)

  10. Thank you!!

    I can see the option in the options page – it is to either use the SEO meta description or not.

    So I set it to “no” but it also did not use the excerpt. Instead it is using the default description I set below for pages that have no description.

    Am I missing something?

    Thanks!

    Jeff

  11. Thank you again!

    I see – and yes it does. But that’s not what I want it to do.

    WordPress allows you to create (optionally) an excerpt separately from the post itself. I use this with all of my posts because many sites (including many RSS readers) use this as the “short description” before a reader clicks on it.

    I would like to use this as the description. Is this possible? I can edit the plugin code if needed, if you can tell me what needs to be changed and where- if this is not currently possible…

    Separately, I am looking to see if there is a way to convert all of my past excerpts to meta descriptions so that I can just use that going forward, but I have not found that yet, so this is the best option for now.

    Thank you for your help!!!

  12. Thanks! no – not the “noteaser” tag… in the plain WordPress implementation, on the “new post” page there is (I think optionally) a box for an “excerpt” – I use that extensively and want that to be the description. I suspect based on what you’ve said so far that it will require code modification, maybe in the plugin, maybe somewhere else.

    Does that make sense?

    Thanks for your help!

    1. Hi, so you know the answer. Provide an appropriate username :

      1. Just check field in option page. Check your inputs, screen_name must be written without @.
      2. If you activated extra field in admin and/or author’s page check the if the screen_name is ok
      3. Check your twitter account and see if thereare some error



Leave a Reply

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

Feel free to use [pre][/pre] to display code.You may also use [b], [u], [i], [del] or [quote].

Notify me of followup comments via e-mail. You can also subscribe without commenting.