Home » Ask (Forum) » How to Create Shortcode for Adsense

Question

In this tutorial I will show to you how to create Shortcode for your Ads (Example: Adsense).

function get_adsense($atts) {
	return '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
		<ins class="adsbygoogle" 
		style="display:block" 
		data-ad-client="ca-pub-xxx" 
		data-ad-slot="xxx"></ins>
		<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
}
add_shortcode('adsense', 'get_adsense');

Now copy paste this code into your theme:

[adsense]
Jul 25, 2016 (4 months ago) - Posted by No Comments

Your Answer

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