Lightning Rank - Private Blog Network

  • Home
  • Done 4 You PBN Service
  • Use My Premium PBN
  • Other Services
    • Amazon Associate Audit
    • Editorial Links
    • Buy Expired Domains
  • Contact
    • Affiliates

Embed GitHub Gists In Your WordPress Posts Without Using Plugins

November 17, 2015 By Jon Gillham Leave a Comment

This WordPress tutorial will show you how to easily embed GitHub Gists into your WordPress posts by placing a small code snippet into your WordPress themes functions.php file. After you insert this code into your thmes functions.php you will be able to embed Github Gists into your WordPress post content by simply pasting the Gists url into your WordPress post editor.


/**
* 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 type="text/javascript" src="https://gist.github.com/%1$s.js%2$s"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);

return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );
}

Filed Under: Blog Tagged With: embed, gist, github, wordpress hack, wp_embed_register_handler

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Services

[wp_cycle]

Recent Posts

  • What It takes to get to #1 in Google
  • Private Blog Network Building Service in 2016 – Is It Still Worth The Risk?
  • UpThemes Scale Back On Theme Options Within Their WordPress Themes
  • Create A WordPress Login Form Shortcode For Your Blog
  • WooThemes Back Online After Malicious Hack & Further DDoS Attack

Our Team

Jon Gillham

Father, Husband and mechanical engineer. Jon has the easy job he builds and tests systems that Kelley, Hmd and their teams execute!
Ahmed Ali

Ahmed is the man that makes sure everything runs smoothly. A true jack of all trades he makes sure each site is built to our high standards!

Quick Contact

Checking...

Ouch! There was a server error.
Retry »

Sending message...

Copyright © 2021 . Experts at Harnessing the Power of Expired Domains to Help You Outrank Your Competition