Hi David.
Hope you are well!?
Just a quick one, and im sure its easy enough. I want to add the product name and image URL into the header for FB Like meta tags, e.g:
<!--FB Like properties-->
<meta property="fb:app_id" content="1234567890" />
<meta property="og:type" content="article" />
<meta property="og:site_name" content="mysite.org.uk"/>
<meta property="og:title" content="<?php print $mainProduct["name"]; ?>" />
<meta property="og:image" content="<?php print $mainProduct["image_url"]; ?>" />
I am guessing there needs to either be some additional PHP somewhere, or different code to achieve this?
Thanks in advance for any help!
Cheers,
Craig
Hi Craig,
Just curious. Is there an SEO benefit for doing this?
let me know. thanks!
Thank you David! I will give it a go today.
The reason for this is for the 'Facebook Like' button. You can let it find the information out itself which is not always accurate, or specify it in the header to be more specific as to what is shown when posted on FB.
http://developers.facebook.com/docs/opengraph
Hi Craig,
You're almost there! The only reason that won't quite work is because the $mainProduct variable isn't created until inside html/product.php, which is called after html/header.php.
Instead of $mainProduct, use $product["products"][0] and that will do the trick, e.g:
<meta property="og:title" content="<?php print $product["products"][0]["name"]; ?>" />
<meta property="og:image" content="<?php print $product["products"][0]["image_url"]; ?>" />
Cheers,
David.
--
PriceTapestry.com