Insert Ads into Your Post Content - BloggerFreeCodes
News Update
Loading...

Tuesday, March 24, 2020

Insert Ads into Your Post Content

1. Find the <head> tag in your blogger template and place latest jquery just below it. Please avoid to use two jquery links, remove older one and use the new version.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script>
2. Second look for this code <data:post.body/> inside Blogger theme and replace it 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>
New Blogger template may have 2 or 3 code. You should have to identify correct one. Generally 2nd instance of is right code to replace in new blogger templates. 3. Now search for tag inside Blogger theme and put following javascript before/ just above it.
<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 the changes made in Blogger theme and have fun.

You can choose your Ad location –

By replacing the value br:lt(1) with br:eq(n), where n= 1, 2, 3… which is the number of line breaks after which Ad will appear in your post. e.g. If you want to show Ad after 5th line break then replace br:lt(1) with br:eq(5) and you are done.

Share with your friends

Add your opinion
Disqus comments
Notification
This is just an example, you can fill it later with your own note.
Done