Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Easily embed and share Github gists on your WordPress blog
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* If a gist has multiple files you can select one using a url in the following format:
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="$s.js%2$s"></script>',
return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment