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.
There are all options you need to add Twitter card (photo and summary) whether they’re required or optional:
- type of card : summary, photo? if you choose photo you can set optional settings.
- your Twitter account (creator) : you or the author
- 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.
- 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>):
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.
Here is the URL to download the plugin