1

I am trying to get an inline like button for each post on the homepage of Tumblr's blogs, like the one similar to http://cicerontheme.tumblr.com/.

I have followed the suggestions on Tumblr — getting the 8 digit reblog code on home page (nearly there...), and included this on my code.

$('a.likeLink').click(function() {
    var post = $(this).closest('.post');
    var id = post.attr('id');
    var oath = post.attr('rel').slice(-8);
    var like = 'http://www.tumblr.com/like/'+oath+'?id='+id;
    $('#likeit').attr('src', like);
});

I have used {PostID} and {ReblogURL}, both which are variable tags of Tumblr, for the values of the id and rel attributes, for the "post" class of a HTML tag, respectively. I have also included the likeit iframe for it to send a request to http://www.tumblr.com/like/....

Now, I am not sure which HTML tag those attributes belong to, so I have viewed the source of Ciceron, and have noticed that they are included in a div tag wrapping the post content and the a tags for the like and reblog buttons. I tried to follow, but it will not work.

I also tried putting those attributes in many different tags, but they still will not work. I am not even really sure if its failure to work is caused by the placement of the attributes anymore.

I will be so gladful if anyone who has gotten it to work would help me get it to work. Thank you.

Community
  • 1
  • 1
caption24
  • 11
  • 1

2 Answers2

1

UPDATE: I've got detailed instructions at: http://like-button.tumblr.com. I've eliminated the need to grab the id from the post and instead put it on the link itself. I've made the entire process cut and paste.

You need to put the rel attribute on a post wrapper than has the post class. That's what her line:

var post = $(this).closest('.post');

Is doing. So it should look like:

<div id="{PostID}" rel="{ReblogURL}" class="post">
    <!-- post goes here -->
</div>
ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
0

Try changing this:

 $('#likeit').attr('src', like);

to:

 $(this).attr('src', like);

and to validate that the like link is correct, you could either do:

 alert(like);

or if you have firebug or chrome do:

 console.debug(like);
Jose Vega
  • 10,128
  • 7
  • 40
  • 57