Skip to content

Instantly share code, notes, and snippets.

@chasereeves
Forked from norcross/gist-shortcode-css.css
Created October 1, 2012 15:45
Show Gist options
  • Save chasereeves/3812595 to your computer and use it in GitHub Desktop.
Save chasereeves/3812595 to your computer and use it in GitHub Desktop.
embed gist shortcode
function gist_shortcode($atts, $content = NULL) {
extract( shortcode_atts( array(
'id' => '',
'title' => ''
), $atts ) );
if (empty ($id) )
return;
$gist = '<div class="github-gist-block">';
if(!empty($title))
$gist .= '<h4>'.$title.'</h4>';
$gist .= '<script src="https://gist.github.com/'.$id.'.js"></script>';
$gist .= '</div>';
// now send it all back
return $gist;
}
add_shortcode ( 'gist', 'gist_shortcode');
/* USAGE
the ID is found in the URL of the gist. For example, this one is https://gist.github.com/gists/3812565/
[gist id="3812565"]
You can add an optional title to show up above the block
[gist id="3812565" title="My Gist Title"]
without the ID present, nothing will fire.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment