How do I add Google Adsense every x posts? - tumblr

I found this example http://wearevanity.co where the new ads are loaded in every page.
In addition to the maximum number of posts allowed by Tumblr. The ads are automatically adjusted to the layout of the page, which makes them add to the look of the blog.
Does anyone know how to achieve this? If so, would you please explain it to us, step by step?

Use {block:Post6} and {block:Post12} to show content on the 6th and 12th posts. Documentation here
Example usage:
{block:Posts}
{block:Photo}Your content blocks here{/block:Photo}
{block:Video}Your content blocks here{/block:Video}
{block:Post6} Your ad code here{/block:Post6}
{block:Post12}Your ad code here{/block:Post12}
{/block:Posts}

Add this
{block:Post6} Your ad code here{/block:Post6}
{block:Post12}Your ad code here{/block:Post12}
above {/block:Posts} to add ads.

I found the solution and the ads look great, and have their own photo-border, adding to the look of the blog. I used bfred's method and placed the ad code right before
{/block:Posts}
However, even though the ads were being loaded after posts 6 and 12, they were inside those posts, sharing the same photo-border, and that didn't add up to the look of the whole theme. So I looked for the line of code that was causing the photos to be organised and have their own space on the grid. In my case this was the line:
<article id="{PostID}" class="entry{block:HasTags}
{block:Tags} tag-{Tag}{/block:Tags}
{/block:HasTags}{block:Photo} photo-border{/block:Photo}">
Once I found it, after trying different placements, I finally placed this line inside
{block:Post6} {/block:Post6}
I also had to change the size of the ads so that the width could match the width of the photo-posts on my blog. So the final code looks like this:
{block:Post6}
<article id="{PostID}" class="entry{block:HasTags}
{block:Tags} tag-{Tag}{/block:Tags}
{/block:HasTags}{block:Photo} photo-border{/block:Photo}">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- page -->
<ins class="adsbygoogle"
style="display:inline-block;width:264px;height:250px"
data-ad-client="ca-pub-7147439154267017"
data-ad-slot="1006289886"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</article>
{/block:Post6}
{block:Post12}
<article id="{PostID}" class="entry{block:HasTags}
{block:Tags} tag-{Tag}{/block:Tags}
{/block:HasTags}{block:Photo} photo-border{/block:Photo}">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- page -->
<ins class="adsbygoogle"
style="display:inline-block;width:264px;height:250px"
data-ad-client="ca-pub-7147439154267017"
data-ad-slot="1006289886"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</article>
{/block:Post12}

Related

Google adsense too small can't customize size

I'm facing problem with Google Adsense size is to small. This is my code I have tried:
I have created new ads same image below:
create new ads screen
This is code look like this
<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Test Ads #2016 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxxxxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
The result looks like this ads still too small:
small ads as result
Please, anybody help me. Thanks you in advance!
If you want to make it any custom size you can go to adsesne dashboard --> ad units then create new one there.
for your code you can just insert this
style="display:block"
instead of this
style="display:inline-block;width:728px;height:90px"
this will make it into block but the better way to create new one>

Click to enlarge on tumblr

I have a tumblr blog on which I post short webcomic stories. I want that when I post a few pages in a single post, they appear small, but when I click it enlarges and one can browse through the comic.
I would like to have something similar to this.
How can I set it up?
You can achieve this by implementing the Pirobox plugin in your theme: http://www.pirolab.it/pirobox/
You will then need to edit the photoset code in your theme to something like this:
{block:Photoset}
<div class="photo">
{block:Photos}
<a rel="gallery" class="pirobox_gall" href="{PhotoURL-HighRes}"><img src="{PhotoURL-500}" alt="{PhotoAlt}"/></a>
{/block:Photos}
</div>
{/block:Photoset}
And make sure you also adjust the photo-post block so they also open in Pirobox when clicked.
{block:Photo}
<div class="photo">
<a rel="single" class="pirobox" href="{PhotoURL-HighRes}"><img src="{PhotoURL-500}" alt="{PhotoAlt}"/></a>
</div>
<div class="caption">
{Caption}
</div>
{/block:Photo}
Add a link to the Pirobox js file in the "head" of your theme.
<script type="text/javascript" src="http://static.tumblr.com/ajtokgb/DfDluuzg8/pirobox_extended.js"></script>
Add this before the "head" or preferably in the "body" section near your other scripts.
<script type="text/javascript">
$(document).ready(function() {
$().piroBox_ext({
piro_speed : 700,
bg_alpha : 0.5,
piro_scroll : true // pirobox always positioned at the center of the page
});
});
</script>
And you will need to style it with CSS of course. You can also look into the "fancybox plugin" which does something similar.
Now when people click on a photo from one of your posts, an enlarged version of the picture will open up and they will be able to browse through the pictures from that specific post.
Note: This method will only work with photo posts. Every theme is different, you will need to adjust the code to suit your theme.

Facebook likebox and Twitter feed are blank on second view in Meteor app

I have put a Facebook likebox and a Twitter feed into my Meteor app's homepage. The first time you navigate there, it works fine. But if you leave the page (while staying on the site), and then return, they are blank. This happens on multiple browsers and on Mac and PC.
I am using Iron Router, and Twitter template code like this:
<template name="twitter_feed">
<div class="news-box">
<a class="twitter-timeline" href="..." data-widget-id="..."></a>
</div>
</template>
with javascript:
Template.twitter_feed.rendered = function () {
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;
js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}
}(document,"script","twitter-wjs");
}
(It's the same if I put the javascript into the template directly using <script>.)
How can I fix this? Here's the site if it helps: Signup Zone.
Thanks!
This is a problem for site that loads content in AJAX.
You need to manually force those widgets to re-parse the page. One workaround could be using jQuery to regenerate the Facebook likebox and Twitter feed each time content changes. Another hack would be setTimeout as follow:
Template.home.rendered = function() {
setTimeout(function() {
twttr.widgets.load(this.firstNode);;
FB.XFBML.parse(this.firstNode);
}, 0);
}
Reference:
https://twittercommunity.com/t/cannot-update-tweet-button-with-ajax/16989
https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/
Here's a solution that doesn't need any scripting.
Use the iframe version of the Facebook likebox code.
For Twitter, there is no iframe version. But we can make one by putting its anchor <a> tag in its own html document, and then including an iframe to that.
Eg. for my Meteor app, I have put this twitter.html into public:
<html>
<head>
<meta charset="utf-8">
<title>Twitter timeline</title>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<a class="twitter-timeline" href="..." data-widget-id="..."></a>
<script>
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;
js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}
}(document,"script","twitter-wjs");
</script>
</body>
</html>
And I have replaced the twitter_feed template with this:
<template name="twitter_feed">
<div class="news-box">
<iframe src="/twitter.html" scrolling="no" frameborder="0"
style="border: none; overflow:hidden; width:404px; height:650px; float:right"
allowTransparency="true"></iframe>
</div>
</template>
And now it shows fine on second and subsequent views.

addThis buttons do not show

I am using the default code. Why don't my buttons show up? Do I need to have the images locally? need absolute path?
<!-- AddThis Follow BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_follow" addthis:userid="myclient"></a>
<a class="addthis_button_twitter_follow" addthis:userid="myclient"></a>
<a class="addthis_button_pinterest_follow" addthis:userid="myclient"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-510e973014b90fdf"></script>
<!-- AddThis Follow END -->
You don't need the images to be stored locally.
You don't need an absolute path
Have you checked if the js is loading properly? You can do that in chrome (developer tools) or firefox (firebug) and check if it is able to get the script loading with no errors.

Tumblr read more expand on the same page

I'm developing a Tumblr site.
When the user clicks on the "read more", the content is revealed and expanded on the same page,how can I do this?
As Tumblr is reworking the UI for editing, the Read More tool may have been hidden from you. Reset your preferences to use the Rich Text Editor to edit posts. The Read More tool is between the bulleted list tool and the image tool. See the screenshot.
Ok, It's a simple script, but it works. Add this code in your theme before tag (or as it should be):
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.spa').click(function(){
$(this).parent().children('div.spb').toggle('normal');
return false;
});
});
</script>
<style type="text/css">
.spb{display:none;}
.spa{cursor:pointer;display:block;}
.spa:after{display:block;content: "{lang:Read more}";margin-bottom:10px;}
</style>
Now, when you write a new text, add to it those things.
Text before Spoiler
<div class="spb">
Text after Spoiler
</div>