Skip to content

Instantly share code, notes, and snippets.

@vinayprajapati
Last active October 25, 2022 08:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vinayprajapati/5893386 to your computer and use it in GitHub Desktop.
Save vinayprajapati/5893386 to your computer and use it in GitHub Desktop.
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
Copy link

ghost 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

@mrtosang
Copy link

mrtosang commented Nov 4, 2021

Great, it actually worked for my site: https://tips.vn

@yalla-shoot-smart
Copy link

Great, I've used it on my website and it works great yalla shoot smart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment