I found this snippet of code at Robert O’Rourkes blog. It easily lets you embed a gist from github to your wordpress posts. Up til now i’ve been using Syntax highlighter evolved which has not been working well all the time. And with this implementation you also get version control.

Start of by adding the following to the functions.php file of your theme:

 * Usage:
 * Paste a gist link into a blog post or page and it will be embedded eg:
 * https://gist.github.com/2926827
 * If a gist has multiple files you can select one using a url in the following format:
 * https://gist.github.com/2926827?file=embed-gist.php
wp_embed_register_handler( 'gist', '/https:\/\/gist\.github\.com\/(\d+)(\?file=.*)?/i', 'wp_embed_handler_gist' );
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) {
	$embed = sprintf(
			'<script src="https://gist.github.com/%1$s.js%2$s"></script>',
	return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );


And when you’re done all you have to do is add a link to a post :

2015-11-05 Update: I don’t use this approach anymore. Github limits the usage for this service. I now use a wordpress highligher plugin instead.