Embed your GIST code in your WordPress blog post without using any plugins

When I write blogs which explains something using code snippet, i used to add the code directly and blockquote it later i find some plugins which will render the code in the readable format with syntax highlighting, later i used to add code snippet in GIST and embed in post using some plugins, recently i got a chance to read this post 

Which lets you to embed the GIST code in your blog post without any additional plugins with simple steps

  1. Login to WP_admin
  2. In WordPress admin console
  3. Goto Appearance > Editor > Select the current theme and click on functions.php
  4. Paste the below code snippet to your WordPress theme function.php file
See the gist on github.

See the gist on github.

See the gist on github.

and simply add your gist url without the username

Say, if this is my URL https://gist.github.com/asvignesh/61b7f687f249a61e3117

add to post as https://gist.github.com/61b7f687f249a61e3117 which will automatically embed as code snippet

if you want to embed particular file, use file query string  https://gist.github.com/56654ec2130b5271f97a?file=MyClass.java 

This site uses Akismet to reduce spam. Learn how your comment data is processed.