How to Insert Google Adsense Ads Inside Your WordPress Posts?

There were many wordpress plugins that perform this task easily, but doing so might eventually increases your wordpress blog’s loading time..
And so, its better to manually perform this task as you can insert adsense ads anywhere inside your wordpress using just a shortcode.

How to Insert Google Adsense Ads Inside Your WordPress Posts?
  1. Go to Dashboard -> Appearance > Editor
  2. Open functions.php file
  3. Insert the following piece of code anywhere in the functions.php file
    function showads() {
    return ‘<script type=”text/javascript”><!–
    google_ad_client = “pub-1234567891011122″;
    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”>
    </script>
    ‘;
    }
    add_shortcode(‘adsense’, ‘showads’);
  4. Save changes.
And now, whenever you write a new blog post, switch to HTML mode and insert the following tag at the position where you’d like to display your Google Adsense ad.

No comments:

Post a Comment