How to Insert Adsense Ads In WordPress Blog

Adsense no doubt one of the most lovely methods to earn with your blogs and websites. Whenever a newcomer starts a blog first thing in his mind came is that How to earn with My Blog. There are many ways you can earn online like Affiliate marketing, sponsor ads, etc.

But one of most valuable and easy method is to earn with Adsense. But the problem is that newcomers don’t know to insert Adsense ads on his WordPress blog. So Today I am going to tell you how you can insert Adsense ads on your blog. Like in posts or sidebars.

What is AdSense:

AdSense (Google AdSense) is an advertising placement service by Google. The program is designed for website publishers who want to display targeted text, video or image advertisements on website pages and earn money when site visitors view or click the ads.

How To Get Adsense Account:

If you have the blog which is at least 6 months old and have a decent traffic (Visitors) with all Adsense requirements you can check here. You can apply to AdSense with the help of this link.

How To Insert Adsense Ads in WordPress Blog:

There are two bests ways you can insert Adsense ads on your blog.

  1. Plugin Method (Recommended)
  2. Coding Method (Not Recommended for New Comers)

Plugin Method:

The plugin is one of the easy ways of inserting Adsense in your blog. There are many plugins out there which you can use to insert Adsense adds. But one of best plugin according to my experience is (Ad inserter).

Install And Activate Ad Inserter WordPress Plugin:

The first thing you need to install and activate Ad inserter plugin. How to install and activate Plugin is briefly Describe by Wp Beginner.

Now in sidebar click settings you ll notice a new option called ad inserter Click on it.

The free version is enough for you. In the free version, you can add up to 16 ads on your blog with the help of plugin blocks.

You ll notice 16 blocks in your plugin homepage.

How to Insert Adsense Ads In WordPress Blog 2

How To Make Adsense Unit:

Make different ads units from your Adsense account. Like one unit for the sidebar and one for posts. Don’t use one unit for all purpose this can ban your account.

  1. On your AdSense account on top click my ads section and click new ad unit.
  2. Name your unit for recognizing purpose and select your size. I recommend you use large Rectangle size.
  3. Click on save and get the code.

Copy your ad units codes and paste in different blocks.

If you want to show your ads in posts, select pages, end of the posts, below title etc then select block below then below block you ‘ll see an option called automatic insertion click on it select your option for add and then save it.

You can also decide whether you want to show ads on only posts or any category, homepage etc.

How To Add code in the sidebar with this plugin:

In Appearance/widgets, you ll notice new widget called ad inserter. just drag that plugin in a sidebar and in options select your ad block.

Coding Method:

If you are one of those peoples who not want to install many plugins for each task then you can use this method. Many plugins can slow down your blog.

How To Add Adsense in the sidebar with Coding Method:

Just go to Appearance/Widgets and select text widget (depends on your WordPress theme). Drag widget in the sidebar and past your add code in a text area and name the widget like (Advertisements, Sponsors, etc).

How To Add Adsense in posts with Coding Method:

This one is complicated and if you are not familiar with coding then I recommend you not use this because this can break your blog.

Open your theme’s functions.php or a site-specific plugin file and paste the following code:


//Insert ads after second paragraph of single post content.

add_filter( ‘the_content’, ‘prefix_insert_post_ads’ );

function prefix_insert_post_ads( $content ) {

$ad_code = ‘<div>Ads code goes here</div>’;

if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );

return $content;

// Parent Function that makes the magic happen

function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = ‘</p>’;
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {

if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;

if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;

return implode( ”, $paragraphs );

To add your AdSense code simply paste your code in where it says “Ads code goes here” on line 9.
If you want to change Paragraph number like which paragraph after add shows. simply change the number 2 to another paragraph number on line 12.

Final Words

I hope you like this tutorial and implanted Adsense in your WordPress. If you need any help just use the comment section and describe your problem. I ll try my best to solve your problem.

5 thoughts on “How to Insert Adsense Ads In WordPress Blog”

  1. If you are going the plugin route, which you should. You should try EAA (Easy AdSense Ads)

    It is super easy to use and has AMP support.

  2. This was seriously the most helpful thing I have ever seen!
    I have been trying to figure out how to put ads on my blog for ages and no website had helpful guides!
    Thank You so much! seriously so helpful!!!

Leave a Comment

at libero. tempus sem, pulvinar dolor Praesent commodo leo. tristique