I make use of Jetpack for this blog in order to add some pretty handy functionality, cross posting to my silo accounts, commenting, and OpenGraph.

Unfortunately, I had to make a couple of tweaks in order to get Opengraph working correctly.

This info is dotted around t’internet, but as an aide-mémoire, I figured I’d consolidate here.

OpenGraph headers not showing

To start, I had to get the OpenGraph headers to show in the first place. This required me to make a minor modification to the code of the plugin, not exactly desirable, but good for the moment.

Basically, Jetpack has a list of plugins that it conflicts with, and if one of those plugins is running, then it disables certain features. Unfortunately, I was running one of these plugins.

I didn’t want to disable the plugin, but after reviewing the code, I figured I wasn’t making use of the conflicting functionality (namely Opengraph, and two sets of opengraph headers is known to cause problems), so I removed the plugin from the list.

This list is found in $conflicting_plugins, which can be found in the function check_open_graph() in the file class.jetpack.php. Comment out the appropriate line at your own risk.

Missing/default open graph image

Next, I wanted to provide a default image for situations when the I don’t have a featured image in the post. This required a slight modification to my theme’s functions.php, as described here and here.

Showing your twitter user instead of @jetpack

Finally, I wanted to use my own twitter handle (@mapkyca) for the twitter card, instead of the default @jetpack.

This was another quick addition to my functions.php, e.g.

add_filter( 'jetpack_open_graph_tags', function( $og_tags ) {
        $og_tags['twitter:site'] = '@mapkyca';
        return $og_tags;
}, 11 );

See this discussion for details.

opengraphlogo Open Graph is a technology that provides information about a website or a website object. Among other things, this is how Facebook and G+ gets details about the youtube video that you just posted.

Support for this was missing from base Idno, and since I wanted it for my other site, I wrote a quick plugin.

This plugin provides open graph headers for your idno site, and detailed descriptions for individual permalinks, but it also provides functionality to extract open graph details from other sites when you post links. This means that you’ll get some extra details displayed about a site when you post a link to it.

Hopefully this’ll be useful to you!

» Visit the project on Github…

Another itch scratched, I would like to introduce a really simple Open Graph plugin for WordPress.

This plugin adds open graph headers to posts and pages on a per post basis.

It has no native interface, instead it listens out for og:* headers as input in the Custom Fields section of WordPress’ edit page and adds the ones it recognises to the page header as meta tags.

Once installed you will be able to add the following tags to posts:

  • og:title (defaults to page title)
  • og:type (defaults to “article”)
  • og:image (URL, no default)
  • og:url is also used, but this is automatically filled in

I wrote this in about an hour so it isn’t all that fancy, and was designed to solve a specific problem for me. Hopefully it’ll be useful to someone else out there.

Feel free to leave comments and send in any patches!

» Plugin page on Github