Photo of David Winter

david winter

Quick and simple Github Gist oEmbed support

WordPress doesn’t come with Github Gist oEmbed support out of the box, which is a shame because sometimes there is nothing quicker than creating a Gist to put in a new tech post by just pasting in the URL.

Well, it is quite simple to drop in with a WordPress hook that I’ve written:

    function($matches, $attr, $url, $rawattr) {
        $embed = "&lt;script src="\"{$url}.js\""&gt;&lt;/script&gt;";

        return apply_filters(

Add that code to your themes functions.php file and then when you’re using the visual editor, if you paste in any Github Gist URL, it’ll automatically be converted. Here’s a little gif to show it in action!

Github Gist oEmbed demo