tumblrsocial-media-like

Tumblr "like-heart-button" script on homepage


How to make a 'like' button for each post without going on permalink page? I mean, even in the homepage, which script can I use to have something like the heart on this page? (mouseover the photos, there's a heart to like the post)


Solution

  • From the page, they're using the javascript:

    $('a.like-link').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);
    }
    

    So post is just the HTML element of the post, they then simply get the id of that post and the 8 char code needed to like or reblog a post. They take all this, throw it into a URL and set it to the source of an iFrame on the page (#likeit)