Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:26:01+00:00 2026-06-02T16:26:01+00:00

EDIT, April 2013: Old code no longer nedeed. Use Tumblr’s new shortcodes for ‘like’

  • 0

EDIT, April 2013: Old code no longer nedeed. Use Tumblr’s new shortcodes for ‘like’ and ‘reblog’ buttons instead!

http://developers.tumblr.com/post/49193689915/attn-fantastic-theme-developers-tumblr-users-can

Old code:

I’m using @ThinkingStiff’s code (https://stackoverflow.com/a/9048446/351320).

Here’s the live example: http://themelab01.tumblr.com/

My html code:

    {block:Posts}
        {block:Text}
            <li id="{PostID}" class="post text">
                {block:Title}
                    <h3><a href="{Permalink}">{Title}</a></h3>
                {/block:Title}

                {Body}
            </li>
            <a href="{ReblogURL}" class="reblog">reblog</a>
            <a href="#" class="like">like</a>
        {/block:Text}

css

#like-it {
    display: none;
}
.liked, .like:hover {

    color: red !important;
}

js

$(document).on('click', '.like', function (event) {

    event.preventDefault();

    var command = $(this).hasClass('liked') ? 'unlike' : 'like',
        post = $(this).closest('.post'),
        oauth = post.find('.reblog').attr('href').slice(-8),
        id = post.attr('id'),
        likeUrl = 'http://www.tumblr.com/' + command + '/' + oauth + '?id=' + id;

    $('#like-it').attr('src', likeUrl);
    $(this).toggleClass('liked');

});

and the empty iframe is at the bottom of the page. However this isn’t working. When I click on ‘like’ the number of liked post in my dashboard increases (where it says “Liked n. posts) but the post does not appear in the Likes page and the text should stay red but it doesn’t. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:26:02+00:00Added an answer on June 2, 2026 at 4:26 pm

    I’ve updated my code recently to make it a cut and paste endeavor. This eliminates the need for jQuery and the post ID, two areas people always have trouble with.

    The tutorial is here: http://like-button.tumblr.com

    Cut and paste the following code block into your theme immediately before </head>. This will give you a like button on each post that looks like the default Tumblr grey heart. It will turn red when you hover over it and when you click it. If you click it again, it will turn grey again and delete the Like.

    <style>
    .my-like {
        background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAARCAYAAAA/mJfHAAABH0lEQVQ4y62T30vCUBiGv/9YuhBLkCA08FdogRFFYFEUhhZNCCQoSESiIOii68pl5qV6s8Eb7+SMHXNs6S7ejZ3zvA+ccT4BICofvS88dJ7w8vqG8WQC754K17lPjrx3z3l8D4YoVaqIrWbcJNbzaHefNZjfXPdy5b0jsO/IRqMxUpmSBnhz2bx1QL79GPbpEePmzhdSyW8fBDL0SK68HwiGCT2S3NiKREaPzP7QRRNPZSHpwm4kMnqkYbQikdEjZv8HK2ubS4nY75mD6WU8qzeXkrHvToBlWSjuHC4kYo99V8bwBnM0/iMiz542myq2bSPskcmR/zPos7lvP8Lv/nGd+/N6c2Xq2KcXhiY6qV1rxwotU3n/NHF8fgW+g9hfsHJlJUYljcgAAAAASUVORK5CYII=) !important;
        height:17px;
        width:19px;
        cursor:pointer;
        display:inline-block;
        vertical-align:top;
    }
    .my-liked, .my-like:hover {
        background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAARCAYAAAA/mJfHAAABSklEQVQ4y2P4//8/Awy/O3fu/905c/4/2779/69Pn/4jy8Hwz/fv/z/buvX/vfnz/7+/eBFFDZj4cOXK/8O+Pv+36+rA8W4zs/8Ply1DUXx/4cL/u0yMUdQdCQ76/+nWLbA6hq+PH//fbW6OogAZ3+zvByu81t6OU80ea6v/P16//s9wqboKpyIYPhYeTlDN1abG/wz7HR0JKiQGH3Bz+8+ww0CfKobtMjb6z0ANg+CGgQKPKt50dfnPcL6wkCqGXaoo/8/w5tgxyg3T0wUnYHBiPJuZSZFhF8pK/8NzACjrgKKWHINAOef3168Iw0D429OnGFmKEAZlJVDKR8mbMAyy4XRqClEGnc3J+f/nxw/MjI6OQflxh6EBzvR0Z9o0rCUKVsNA+MuD+/9PJiSgGHQmPf0/KDhw6cFpGAy/OnAAbOibEyf+E1ILAFBjDrchm7KrAAAAAElFTkSuQmCC) !important;
        height:17px;
        width:19px;
        cursor:pointer;
        display:inline-block;
        vertical-align:top;
    }
    </style>
    <script>
    window.onload = function () {
    document.body.insertAdjacentHTML( 'beforeEnd', '<iframe id="my-like-frame" style="display:none;"></iframe>' );
    document.addEventListener( 'click', function ( event ) {
        var myLikeLink = event.target;
        if( myLikeLink.className.indexOf( 'my-like' ) > -1 ) {
            var myLikeFrame = document.getElementById( 'my-like-frame' ),
                liked = ( myLikeLink.className == 'my-liked' ),
                command = liked ? 'unlike' : 'like',
                reblog = myLikeLink.getAttribute( 'data-reblog' ),
                postId = myLikeLink.getAttribute( 'data-id' ),
                oauth = reblog.slice( -8 ),
                likeUrl = 'http://www.tumblr.com/' + command + '/' + oauth + '?id=' + postId;
            myLikeFrame.src = likeUrl;
            liked ? myLikeLink.className = 'my-like'
                : myLikeLink.className = 'my-liked';
        };
    }, false );
    };
    </script>
    

    Then cut and paste the following button code into your theme where you want your like button to be (this must be inside your {block:Posts} block).

    Code:

    <div class="my-like" data-reblog="{ReblogURL}" data-id="{PostID}"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I used, finally, inotify. As stefanB says, inotify is the thing to use.
EDIT: OK, I believe the following solutions are valid: Use the jQuery AOP plugin.
Edit: I would like to model a 1 to 0:1 relationship between User and
Edit: I just moved my HTTPRequest code into the onCreate, and now all of
I have this code: function render_message(id) { var xmlHttp; xmlHttp=new XMLHttpRequest(); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4)
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: Since you are asking for specifics, consider a photo-sharing site (like Flickr or
EDIT: changed the title to fit the code below. I'm trying to retrieve a
EDIT - I was able to fix this problem using code from 'Farray' with
EDIT: Duplicate of Should Entity Framework Context be Put into Using Statement? I've been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.