Skip to content

Instantly share code, notes, and snippets.

@imuhammadshoaib
Created March 26, 2019 15:01
Show Gist options
  • Select an option

  • Save imuhammadshoaib/d595be5ad830903bf1f14bca8a95250d to your computer and use it in GitHub Desktop.

Select an option

Save imuhammadshoaib/d595be5ad830903bf1f14bca8a95250d to your computer and use it in GitHub Desktop.
WordPress Shortcode
function get_adsense($atts) {
return '<script type="text/javascript"><!--
google_ad_client = "pub-546321545321589";
/* 468x60, created 9/13/10 */
google_ad_slot = "54321565498";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
}
add_shortcode('adsense', 'get_adsense');
/*That’s it! The first parameter passed in is the name of the shortcode, so in our case, ‘adsense’ tells WordPress to create the [adsense] shortcode. The second parameter designates the function that will be called when the new shortcode is encountered. Again, in our case, ‘get_adsense’ tells WordPress to replace [adsense] with the results of our get_adsense method.*/
@imuhammadshoaib
Copy link
Copy Markdown
Author

Shortcode [adsense]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment