Today I’m gonna show how to Embed Google Adsense anywhere in your post, you can put your ad in anywhere in post like after the image, after a paragraph or in the middle of the post.
Don’t forget to Subscribe to Email Newsletter, Follow us on Twitter and Like us on Facebook – for recent updates.
Just follow the below steps:
1. First you need add the following code in your function.php file of your theme
function showads() {
return '<script type="text/javascript"><!--
google_ad_client = "pub-2027406933994659";
/* 300x250 Sidebar */
google_ad_slot = "5310377007";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
}
add_shortcode('adsense', 'showads');
Note: Don’t forget to change the adsense code otherwise it will display my ads on your own site.
2. Once you saved the functions.php file, you’re now able to embed your adsense code on your posts and display it exactly where you want.
To do so, simply paste the following code on the editor, in html mode of your post:
[adsense]
Do you know any other wordpress tip? Let us know
Don’t forget to Subscribe to Email Newsletter, Follow us on Twitter and Like us on Facebook – for recent updates.
How to blend the ads according to the content? So that it looks same as the content?
You need to set the color of title, URL and text according to your theme so that it looks like it is the part of the website. You can do this by logging to you adsense account & modify your ad type and than set the color according to your requirement.