Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adsense in Middle of Post: Blogger - Advanced Practices (Part 2)
//Copyright 2013 by AJ Banda + Vinay Prajapati
//http://www.techprevue.com/2013/06/adsense-in-middle-of-post-blogger_30.html
//1. Below <head> place this
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script>
//2. Replace <data:post.body/> with the following code
<div id="PostBody">
<data:post.body/>
</div>
<div id="AdCode">
<div style='margin:5px 0;text-align:center;clear:both;'>
<!-- Ad Unit Code Here -->
</div>
</div>
//3. Now just before </body> tag paste following js
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<script>
$AdCode = $("#AdCode").html();
$("#PostBody br:lt(1)").replaceWith($AdCode);
$("#AdCode").remove();
</script>
</b:if>
//4. Save template :D
@pawansoobhri

This comment has been minimized.

Copy link

@pawansoobhri pawansoobhri commented Nov 5, 2016

It is showing two ads in my post. I just want to show one

@chdelacr

This comment has been minimized.

Copy link

@chdelacr chdelacr commented Feb 10, 2019

It is showing two ads in my post. I just want to show one

You need to use a code of a sync ad, not an async one. It works in my site: https://frenegeek.com

@chantroiviet

This comment has been minimized.

Copy link

@chantroiviet chantroiviet commented Nov 13, 2019

It is showing two ads in my post. I just want to show one

Me too, do you solution show one ads?. i want show in https://choluoi.com

@ajaymalik14

This comment has been minimized.

Copy link

@ajaymalik14 ajaymalik14 commented Apr 17, 2020

I made a pure Js function similar to this, Check this out: https://github.com/ajaymalik14/place-ad-inside-article-usign-pure-JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.