Mobile app version of vmapp.org
Login or Join
Samaraweera270

: Automating twitter card on a dynamic web page 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

@Samaraweera270

Posted in: #TwitterCard

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

celebrationinvites.com/boho_wild_roses_bridal_shower_invitations_zazzle_invitation2-256484831955683674.html

this is the basic page

celebrationinvites.com/product.php

the validator
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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

1 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley505

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme