Recently I have added a “Like” feature to the blog, which allows you to… well, like my posts!

The Like button is situated under the post, after the category and the tags.

To add it there, I slightly modified an already existing plugin, WTI Like Post. If you’d like to know more, continue reading.

This nice plugin adds a a very customizable set of Like and Dislike buttons after (or before) the content of every post. To display only the Like button and make it appear as a link in any place you want, you have to slightly modify two of the plugins files and one of the files of the theme you are using.

1. Step: open wti_like_post_site.php and locate the following piece of code:

$wti_like_post .= "<div class="wti-clear"></div>";

Below it (but before the closing }) add the following snippet (you can call the new variable any way you’d like).

$wti_like_post_mine = "<a class='lbg-" . $style . " like-" . $post_id . " jlk' href='" . $ajax_like_link . "' data-task='like' data-post_id='" . $post_id . "' data-nonce='" . $nonce . "'>Like</a>";
$wti_like_post_mine .= " (<span class='lc-" . $post_id . "'>" . $like_count . "</span>)";

This will create a “Like” link (check it out on the bottom of this post), which will work the same way as the button the plugin would generate. The span will display the Like count.

After the closing } a variable is returned inside if ($arg == 'put') {. You should rename the variable to the newly created one (in my case it’s $wti_like_post_mine).

2. Step: in the same file find add_filter('the_content', 'PutWtiLikePost'); and comment it out (just add // preceding it).

3. Step: the last step consists in editing the file that contains the location where you want to display the new Like link. In my case it was entry-footer.php.

Add the following code:

<?php GetWtiLikePost();?>

And that’s it!

You can now leave a comment and I will come like your post! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *