Using Tumblr Like Button with Infinite Scroll

First you need to add a unique post ID to each of your posts:

<div class="entry masonry-brick" id="{PostID}">...</div>

The documentation mentions requesting the like status once the new posts (or new page) has been appended / loaded:

function( newElements ) {
    var $newElems = $( newElements ).css({
        opacity: 0
    });

    // Create Array of $newElems IDs
    var $newElemsIDs = $newElems.map(function () { 
        return this.id; 
    }).get();

    $newElems.imagesLoaded(function(){
        $newElems.animate({
            opacity: 1
        });
        $container.masonry(
            'appended', $newElems, true
        );

        // Let's just see what we have, remove console.log() if working
        console.log($newElems, $newElemsIDs);


        Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
    });
});

I hope that points you in the right direction.

Leave a Comment