
And this post is about how to add Adsense inside post for template default version, auto read more with thumbnail script, and read more with snippet both top and bottom post
No demo live for this tutorial but we have tested and works well
CSS Code
First, we create a CSS code. Go to Template > Edit HTML and add this code below before]]></b:skin>
.ad-inside{
float:right;
width:336px;
margin:0 0 30px 30px;
padding:0;
}
.ad-inside p{
float:left;
background:#ededed;
padding:2px 5px;
font-size:11px;
color:#000;
line-height:normal
}
Note :
- float on the right
- ad size 336*280px
- You can edit and adjust the position and size
- float on the right
- ad size 336*280px
- You can edit and adjust the position and size
- Responsive Google Adsense
- How To Make Responsive Adsense Link Ad Unit
- Type And Functions Conditional Tag Code Blogger
Read also
Now, we go to HTML
Template Default Version
Default version is a default template from Blogger. No added auto read more.
1. New Template
For new template, the HTML code like this<b:if cond='data:blog.metaDescription == ""'>
<!-- Then use the post body as the schema.org description,
for good G+/FB snippeting. -->
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='description articleBody'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
<b:else/>
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='articleBody'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
</b:if>
Then, please note code
<data:post.body/>
(you can see 2 codes. choose the first one)Adsense At The Top
For Adsense at the top, copy and paste this code below before
<data:post.body/>
<div class='ad-inside'>
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- optional code -->
</div>
Adsense At The Bottom
For Adsense at the bottom, copy and paste this code below after
<data:post.body/>
<div class='ad-inside'>
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- optional code -->
</div>
And This is the complete code both Adsense top and bottom post for default template new version
<b:if cond='data:blog.metaDescription == ""'>
<!-- Then use the post body as the schema.org description,
for good G+/FB snippeting. -->
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='description articleBody'>
<div class='ad-inside'> <!-- Ad Top -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional code -->
</div>
<data:post.body/>
<div class='ad-inside'> <!-- Ad Bottom -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional code -->
</div>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
<b:else/>
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='articleBody'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
</b:if>
2. Old Template
For old template, the HTML code like this<div class='post-body entry-content'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
Please note code
<data:post.body/>
. Some template have 1 but others have 2. If you have 2 codes, choose the second oneAdsense At The Top
For Adsense at the top, copy and paste this code below before
<data:post.body/>
<b:if cond='data:blog.pageType == "item"'>
<div class='ad-inside'>
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
</b:if>
Adsense At The Bottom
For Adsense at the bottom, copy and paste this code below after
<data:post.body/>
<b:if cond='data:blog.pageType == "item"'>
<div class='ad-inside'>
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
</b:if>
And This is the complete code both Adsense top and bottom post for default template old version
<div class='post-body entry-content'>
<b:if cond='data:blog.pageType == "item"'>
<div class='ad-inside'> <!-- Ad Top -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
</b:if>
<data:post.body/>
<b:if cond='data:blog.pageType == "item"'>
<div class='ad-inside'> <!-- Ad Bottom -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
</b:if>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
Template Support Script Auto Read More With Thumbnail
For template support script auto read more with thumbnail, we use script auto read more with thumbnail like this below. Please note the code. Make sure the auto read more code similar with your template. For other auto read more, maybe in next post.<script type='text/javascript'>And
var thumbnail_mode = "float" ;
summary_noimg = 500;
summary_img =70;
img_thumb_height = 230;
img_thumb_width = 280;
</script>
<script type='text/javascript'>
//<![CDATA[
/*
Auto-readmore link script, version 2.0 (for blogspot)
(C)2008 by Anhvo
visit http://en.vietwebguide.com to get more cool hacks
*/
function removeHtmlTag(strx,chop){
if(strx.indexOf("<")!=-1)
{
var s = strx.split("<");
for(var i=0;i<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
strx = s.join("");
}
chop = (chop < strx.length-1) ? chop : strx.length-2;
while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++;
strx = strx.substring(0,chop-1);
return strx+' ...';
}
function createSummaryAndThumb(pID){
var div = document.getElementById(pID);
var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length>=1) {
imgtag = '<span style="float:left; padding:0;margin:0"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/></span>';
summ = summary_img;
}
var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
div.innerHTML = summary;
}
//]]>
</script>
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='articleBody'>
<b:if cond='data:blog.pageType == "static_page"'>
<data:post.body/>
<b:else/>
<b:if cond='data:blog.pageType != "item"'>
<div expr:id='"summary" + data:post.id'><data:post.body/></div>
<script type='text/javascript'>createSummaryAndThumb("summary<data:post.id/>");</script>
</b:if>
<b:if cond='data:blog.pageType == "item"'>
<data:post.body/>
</b:if>
</b:if>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
Adsense At The Top
For Adsense at the top, copy and paste this code below before
<data:post.body/>
(choose the third code)<div class='ad-inside'> <!-- Ad Top -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
Adsense At The Bottom
For Adsense at the bottom, copy and paste this code below after
<data:post.body/>
(choose the third code)<div class='ad-inside'> <!-- Ad Bottom -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
And This is the complete code both Adsense top and bottom post for template support script auto readmore with thumbnail
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='articleBody'>
<b:if cond='data:blog.pageType == "static_page"'>
<data:post.body/>
<b:else/>
<b:if cond='data:blog.pageType != "item"'>
<div expr:id='"summary" + data:post.id' itemprop='articleBody'>
<data:post.body/></div>
<script type='text/javascript'>createSummaryAndThumb("summary<data:post.id/>","<data:post.title/>","<data:post.url/>","<data:post.timestamp/>","<data:post.author/>");</script>
</b:if>
<b:if cond='data:blog.pageType == "item"'>
<div class='ad-inside'> <!-- Ad Top -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
<data:post.body/>
<div class='ad-inside'> <!-- Ad Bottom -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
</b:if>
</b:if>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
Template Support Read More With Snippet
First, please check this post about create summary post no Javascript required from BloggerBuster.com because this tutorial based on that postAdsense At The Top
For Adsense at the top, copy and paste this code below before
<data:post.body/>
(choose the second code)<div class='ad-inside'> <!-- Ad Top -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
Adsense At The Bottom
For Adsense at the bottom, copy and paste this code below after
<data:post.body/>
(choose the second code)<div class='ad-inside'> <!-- Ad Bottom -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
And This is the complete code both Adsense top and bottom post for template support read more with snippet
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='articleBody'>
<b:if cond='data:blog.pageType != "item"'>
<b:if cond='data:post.snippet'>
<b:if cond='data:post.thumbnailUrl'>
<div class='Image thumb'>
<img expr:src='data:post.thumbnailUrl'/>
</div>
</b:if>
<data:post.snippet/>
<b:if cond='data:post.jumpLink != data:post.hasJumpLink'>
<div class='jump-link'>
<a expr:href='data:post.url + "#more"' expr:title='data:post.title'><data:post.jumpText/></a>
</div>
</b:if>
<b:else/>
<data:post.body/>
</b:if>
<b:else/>
<div class='ad-inside'> <!-- Ad Top -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
<data:post.body/>
<div class='ad-inside'> <!-- Ad Bottom -->
<!-- YOUR ADSENSE CODE HERE -->
<p>Advertisement</p> <!-- Optional Code -->
</div>
</b:if>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
Basically, this is not only for Adsense. You can put another ads or banner image inside post with that.
Let me know if you have suggestion for another template version. I'll try to help
0 Comments