twitter-card

How to show twitter summary card with tweets?


I have the following meta tags on all pages of my site :

                <meta name="twitter-card" content="summary">
                <meta name="twitter-title" content="$row["title"] />
                <meta name="twitter-description" content="$row["description"]>

When I send a link from my site to twitter timline, I dont see the view summary option in my tweets. My domain is varified for twitter summary card and I echoed the data from DB, it is working file but it is not showing in tweets. Does someone know how to fix it?


Solution

  • I see a few minor issues with the code you're using, which are:

    1. On Twitter's website, in sample code, there are 5 tags while your're using only 3.
    2. Also, the name of the tags is different than what twitter has used in their sample code.
    3. Lastly, content attribute in the last two HTML tags does not have a closing quotation (").

    Try changing your code to something like the following. (Note: You'll need to edit some of the code as per columns in your db)

    <meta name="twitter:card" content="$row['summary']" />
    <meta name="twitter:site" content="@your-twitter-handle" />
    <meta name="twitter:title" content="$row['title']" />
    <meta name="twitter:description" content="$row['description']" />
    <meta name="twitter:image" content="$row['img']" />
    

    Source: Twitter