Adding Open Graph Protocol Meta Tags to a Magento/WordPress Fishpig Site

David Hellowell

Adding Open Graph Protocol Meta Tags to a Magento/WordPress Fishpig Site

If you are not aware already the guys at Fishpig created a great extension to integrate a WordPress blog within your Magento site. It allows you to seamlessly display WordPress content within your Magento skin and is pretty great, however there are a couple of things it doesn’t quite do. One of these is bringing through extra meta information that you might want for controlling how your blog posts look when shared on facebook.

We have been making use of Hitreach’s ‘Open Graph Protocol in Posts and Pages‘ to add the extra data to the post and with a little tweak to your Magento theme you can pull through this data.

The key file to edit is /app/design/frontend/default/YOURTHEME/template/page/html/head.phtml (replacing YOURTHEME for the name of your theme) and add in the following code to the bottom:

getRequest()->getRouteName() == "wordpress")
if($wp_post = Mage::registry('wordpress_post') )
if( $ogp_data = unserialize($wp_post->getCustomField('OGP') ) )
foreach($ogp_data as $k => $v)
echo "";

And that is it!

How it works is it checks if the currently loaded page is part of the wordpress module and their is a currently viewing post in the registry and check is done for OGP data and if set it is looped through and each tag echo’d out into the HTML.


Got a project in mind? Our friendly team would love to hear from you

Get In Touch

Want more information?

View Our ResourcesView Our Work

For exclusive digital marketing news and resources, subscribe to the Blueclaw insight list.