Skip to content

Instantly share code, notes, and snippets.

@technoknol
Created January 27, 2014 06:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technoknol/8644150 to your computer and use it in GitHub Desktop.
Save technoknol/8644150 to your computer and use it in GitHub Desktop.
wordpress create your own shortcode.
<?php
/********************************
This code will allow you to create your own shortcode.
*************************************/
// SHORTCODE FOR GOOGLE ADSENSE
function google_adsense() {
return '<script type="text/javascript"><!--
google_ad_client = "<em>your client id</em>";
google_ad_slot = "<em>your ad slot id</em>";
google_ad_width = <em>width</em>;
google_ad_height = <em>height</em>;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
}
add_shortcode('adsense', 'google_adsense');
// USE THIS CODE WHERE YOU WANT TO DISPLAY GOOGLE AD
[adsense]
// SHORT CODE FOR GIT
function show_git($atts) {
extract(shortcode_atts(array('id' => null), $atts));
if( $id != null) {
return '<script src="http://gist.github.com/'.$id.'.js"></script>';
}
}
add_shortcode('gist-git', 'show_git');
// USE THIS CODE WHERE YOU WANT TO DISPLAY GIT | Real GIT Example
[gist-git id=8559021]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment