google-adsense

Most of the people using Google adsense on there blog website. To implement the google adsense on wordpress themes like sidebar.php we can use shortcode on the editor.

1.Open the functions.php file in your theme and paste the following code. Don’t forget to modify the JavaScript code with your own AdSense code!

function showads() {
return '<div id="adsense"><script type="text/javascript"><!--
google_ad_client = "pub-XXXXXXXXXXXXXX";
google_ad_slot = "4668915978";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>

<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
</script></div>’;
}

add_shortcode(‘adsense’, ‘showads’);

2. Once you have saved functions.php, you can use the following shortcode to display AdSense anywhere on your posts and pages:
[adsense]
It’s very easy to implement google adsense any where of your post.

Advertisements