When I first started writing tutorial blog posts that involved posting code snippets I would add the code directly into the posts and use the SyntaxHighlighter Evolved plugin to render it readable on the front end. This sometimes worked, and sometimes didn’t.
Eventually I started using Gists on GitHub as public repositories for my code snippets, and installed a plugin on my site to embed and display the Gists in the blog posts. This worked okay, but it depended on a plugin.
Then I ran across a post by Christian Engvall (who cited Robert O’Rourke) with a way to embed Gists without a plugin, simply by placing the following code in your functions.php file or in a mu-plugin.
Simply add the Gist URL to your post
With that code in place, all you need to do is add the URL of a Gist into your post (or page) on its own line and the Gist will be embedded in the post on the front end.
Remove your username from the Gist URL
Gist adds your username to the Gist URL, and if you leave that username in the URL in your post then it won’t embed the Gist – it will simply display the URL.