Embed Google AdSense Anywhere in Your Post

Embed Google AdSense Anywhere in Your Post

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.

Written by
AsHok Jain
Join the discussion

2 comments
    • 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.

Let’s get social

Web design blog for professionals with topics focusing on useful design techniques, design best practices and design inspiration. Subscribe for updates!

15585

JOIN OUR GROWING LIST OF SUBSCRIBERS!

Following our blog is a great way to make sure that you are up to date on the latest and greatest Freebies and WordPress news.

15856