1

I have read all the posts with search term "twitter card" I am not an expert in coding, just trying my hand at automating twitter card so any help is much much appreciated

i added this to product.php

    <?php include"header2.php" ; ?>

    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" value="<?php echo $title ?>" >
    <meta name="twitter:description" value="<?php echo $description ?>" >

where header2.php is

    <?php 
    echo "<meta name='description' content='$description' />"; 
    echo "<meta name='title' content='$title' />"; 
    ?>

this is the dynamically pulled page

    www.celebrationinvites.com/boho_wild_roses_bridal_shower_invitations_zazzle_invitation2-256484831955683674.html

this is the basic page

    www.celebrationinvites.com/product.php

the validator https://cards-dev.twitter.com/validator

shows this error4

INFO: Page fetched successfully INFO: 8 metatags were found INFO: twitter:card = summary_large_image tag found ERROR: Invalid value (message: Field description failed to validate because: text expects tag property, but not found in Map().)

I know I am messing up the automation code, googled a lot, just don't know what I need to fix please help

Thanks

1 Answer 1

2

Your meta description and meta title are written wrong. In order to be valid opengraph you need to use the property attribute not the name attribute. So in order to fix this all you need to do is change header2.php to...

<?php 
echo "<meta property='og:description' content='$description' />"; 
echo "<meta property='og:title' content='$title' />"; 
?>



Update #1
A quick check of your site shows that the og:title, twitter:title, og:description, and twitter:description tags are empty. These must contain the appropriate text and can't be blank. You are also missing the twitter:site and twitter:creator tags which will cause a validator problem next and will need to be added as they are required.

What you effectively need in your head section is a block that looks like this...

<meta property='og:description' content='<?php echo($description) ?>' />
<meta property='og:title' content='<?php echo($title) ?>' />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" value="<?php echo($title) ?>" >
<meta name="twitter:description" value="<?php echo($description) ?>" >
<meta name="twitter:site" value="Site Name" />
<meta name="twitter:creator" value="<?php echo($author) ?>" />

The twitter:site meta tag should be manually defined as it remains the same across all pages (It is just the name of your site). The creator meta tag can be either manually defined as the site name as well if you want all content to show as being authored by the site and not a specific user or you can dynamically echo it out by specifying the $author PHP variable to allow you to specify the actual author of the articles.

NB: The code you supplied was missing the twitter:site and twitter:creator meta tags which are required by Twitter.

16
  • umm still getting this error in validator Log INFO: Page fetched successfully INFO: 10 metatags were found INFO: twitter:card = summary_large_image tag found ERROR: Required meta tag missing (twitter:text:description) ERROR: Required meta tag missing (twitter:text:title) Feb 4, 2017 at 17:41
  • I have rechecked your site and tested it with a local copy and have updated my answer based on my testing of your code. The update contains the block you will need to have in your head section to make it work. I have tested this on my server and it has worked to get a card displaying. If you want to have additional data added you will just need to check the Twitter meta guide on what additional meta tags to display. Feb 4, 2017 at 23:55
  • that's the whole point ! if i add this block ,of course it will work but i will have to manually put title description,..,image e.t.c in validator it shows some text description here and what i am wanting as my original question to automatically pull title and description for the page to show "the title of the page" and not "page title" to show "the description of the product" and not "some description here" i want to auto pull title and description this is why i was trying to use og and echo ..e.t.c Feb 6, 2017 at 8:48
  • Okay from your comment you seem to be saying that you have the page title and page description loaded as PHP variables which you want to use to populate the meta tags. In line with this I have updated my code block in my answer to add the PHP echo statements to pull the title and description variables and echo them into the right spots. One thing I did note through my tests was that you didn't have the twitter:site and twitter:creator meta tags defined in the sample code you provided and they are needed so I have added them to my code block. Feb 6, 2017 at 9:57
  • 1
    AND THE IMAGE IS ALSO WORKING NOW! woohoo! Feb 7, 2017 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.