How To Insert AdSense Ads In A Loop In WordPress

Google Adsense is one of the leading platform for the publisher to earn good amount of revenue. Inserting AdSense Ads in proper way is must necessary to generate good revenue. AdSense has some criteria which should be fulfilled first in order to show ads on your website. Once the criteria are completed then the ads will be live on your site. Several platforms on which you can run your website and run Ads. But in this article, we are going to see how to Insert AdSense Ads In A Loop In WordPress which will also increase your ads click rate.

In WordPress, the ads can be inserted between the articles which will increase your revenue. Google AdSense can insert after every 3rd paragraph or any of the paragraphs with the help of snippet code by Google.

Also Read: How To Get AdSense Approval For WordPress

How To Insert AdSense Ads In A Loop In WordPress

There are several plugins which allows to Insert Adsense Ads In WordPress at different places. But these plugins are paid and might cost a bit higher and also may not provide to insert ads into the paragraph you desire.

If you want to use the free method provided by Google AdSense then use the following code of the snippet to Insert Adsense Ads inside content in WordPress.

Add this code inside functions.php your theme. – Gist

//Adding AdSense ad unit inside the article
//Insert ads in loop to your desired article
add_filter( ‘the_content’, ‘prefix_insert_post_ads’ );
function prefix_insert_post_ads( $content ) {
$ad_code = ‘<script async src=””></script>
<!– inContent –>
<ins class=”adsbygoogle”
(adsbygoogle = window.adsbygoogle || []).push({});
if ( is_single() ) {
return prefix_insert_after_paragraph( $ad_code, 3, $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 ( ( ($index + 1) % $paragraph_id ) == 0 ) {
$paragraphs[$index] .= $insertion;
return implode( , $paragraphs );
Please leave a comment below if you are facing any problems to Insert AdSense Ads In A Loop In WordPress
You May Like:

Recent Articles

Install Phoenix OS On VirtualBox In Linux

You might be thinking to use your favorite Android Apps on your Linux Machine. Now you can Install Phoenix OS on VirtualBox In Linux...

Update Nameserver of Com.Np Domain

In the last article, we discussed about how to register the domain for free. After having a free domain you can use...

How To Register Free .Com.Np Domain In Nepal

Mercantile Communication is providing free .np ccTLD domain to every people and student searching for free domain for their projects, blogs, and companies. Register free...

How To Get Google AdSense Approval in Nepal

Google AdSense is one of the best Ads provider for the publishers. If you are worrying much about that your Google AdSense is not...

How To Fix WP Mail SMTP For Gmail After Changing Password

WP Mail SMTP is a WordPress plugin by WP Forum which is the most popular plugins for email service. Recently there are some issues...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Get the daily news in your inbox