• Hi everyone,

    I want to know how to add like button on my posts.

    The main idea is about create counter increased by one when someone clicked on like button.

    I want to do this “programmatically” without use any plugin.

    Can anybody help me? Thanks in advance

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    For the best user experience, clicking the Like button should send an AJAX request to the server. The server side script can add the Like to a running total somewhere. Where depends on what is being liked. If a post, post meta is a good place.

    Depending on how important it is to prevent voting fraud, the server side script should take some measure to prevent one person from liking the same thing multiple times. It’s probably impossible to fully protect against fraud, but requiring users to be logged in and keeping track of their likes in user meta would go a long way.

    Some folks have leveraged the comment system into a Like Button feature. I’m not sure it’s worth doing so. If you write your own code then you know exactly what it’s doing. I assume that is in part why you do not want to use a plugin.

    A nice touch would be to have javascript increment the count shown on the page (if there is a count) after the vote is registered server side. If nothing else, a brief modal thanking the user could be shown so they know their vote was registered.

Viewing 1 replies (of 1 total)

The topic ‘Add like button to posts’ is closed to new replies.