Do you want to show your Adsense ads on your WordPress posts in different places? If yes, this post is specially for you. We will discuss here to build a shortcode for an ad to display on your WordPress posts, later you may add it manually on different places of your choice in posts. There are so many plugins to add this functionality on WordPress posts, but if you are using so many plugins on your WordPress blog, it may reduce the loading time of your overall WordPress blog. It is better not to use plugins for basic requirement or features.

how to add adsense anywhere in wordpress
Adsense Ads anywhere in WordPress

Lets talk about why to use Google Adsense ads manually in your WordPress posts.

Showing Adsense Ads Anywhere Inside WordPress Posts to Generate More Revenue

We all know that the ad placement is directly proportional to the generated revenue. Google Adsense team also tells to their publishers showing ads on above the fold area leads more revenue. It also depends that what type of traffic you have such as from, search engines, social media sites or email subscribers. Too many ads on above the fold area will trigger search engines to ban your blog so don’t make this mistake. I recommend you to show only one ad on above the fold area in your blog. You may show this ad block to your sidebar or in the starting of your post. If you are showing your ads in the very low bottom area, you are losing revenue. If you a regular reader on the web, you know most of the blogs showing their ad before and after the content area. When the content ends, it goes to the bottom area of the blog. Here is a chance to optimize this ad block to generate more revenue than this place by manually add it inside the post.

The other advantage is, if you have huge readers for your blog, they regularly visit your blog to read since, your layout is fixed so they are well known to your ad placements, content area and sidebar. When a reader knows that this is a placement for advertisement, he/she will never click on it. That is why mostly all the bloggers, tech geeks never click on the ad. It is better to change the ad placement in your posts so that the readers could not catch the eye on the advertisements by the fixed ad placement. Therefore, here is a quick guide to add Adsense ads anywhere on WordPress.

Show Google Adsense Ads Anywhere on WordPress

  1. Log into WordPress Dashboard » Appearance » Editor, and open Theme Functions (functions.php) file.
  2. Add the following code into your theme functions file. Just copy the following code and paste it to the bottom of functions.php file.
    function wpads() {
    return 'Your Adsense Ad Code Here';
    }add_shortcode('adsense', 'wpads');

    Once you add the above code, you are now able to embed your Adsense code anywhere in your posts. Just paste the following code in your post editor where you want to display the ad.

    [adsense]
  3. This is a shortcode method to display anything anywhere in your post. By default, this shortcode does not work in the widget area. If you want to use shortcodes in your WordPress widget, paste the following code once into your theme functions file.
    add_filter('widget_text', 'do_shortcode')
  4. Use a shortcode in your template files, you can access them by;
    do_shortcode("[adsense]");

Alignment of Adsense Ads in WordPress posts when using Shortcodes

  1. Left Align: wrap your shortcode with <div style=”text-align: left;”></div>. For example;
    <div style="text-align: left;">
    [adsense]
    </div>
    
  2. Right Align: wrap your shortcode with <div style=”text-align: right;”></div>.
  3. Center: wrap your shortcode with <div style=”text-align: center;”></div>.
  4. Float Left: wrap your shortcode with <div style=”float: left;”></div>.
  5. Float Right: wrap your shortcode with <div style=”float: right;”></div>.

I hope, you enjoyed this article. Please consider sharing it!

NO COMMENTS

Leave a Reply