WordPress Like Button Rating Plugin


Add a Like button to posts, pages, comments, WooCommerce products, BuddyPress, bbPress and custom post types!

Get instant rating statistics and insights!

Sort content by likes!

Download Live Demo

41 themes

                                                                                                                    
     

Compatibility



WooCommerce
bbPress
BuddyPress

Google Rich Snippets

Make your site look appealing to the visitors on search engine results pages!
Boost search engine rankings!
Increase clicks!

Google Rich Snippets
Learn more on Google Rich Snippets

Custom Themes

              

              

Mobile Friendly

Sorting content by likes

Sorting content by likes

92 parameters

  • Adjust any single aspect of the Like Button to best suit your needs.
  • Create whatever text you want for the like & dislike button.
  • Customize appearance with CSS.
  • Like box displaying users who liked an item.
  • Works on websites fully cached with WP Super Cache, Quick Cache, CloudFlare, etc.

Shortcodes

  • Shortcode to display the Like button inside a post/page: [likebtn]
  • Shortcode to display the most liked content: [likebtn_most_liked]
  • Shortcode to display content liked by the current authenticated user: [likebtn_liked_by_user]
  • Shortcodes to display the number of likes and dislikes: [likebtn_likes] [likebtn_dislikes] [likebtn_user_votes]
  • Shortcode to disable the Like button in a post/page: [likebtn_off]

BuddyPress Integration

  • Recording like and dislike actions in BuddyPress activity stream (votes in private groups are NOT displayed in the public activity stream)
  • Custom templates for snippets in BuddyPress activity stream
  • BuddyPress notifications for authors when authenticated users like or dislike author's content


Screenshots

Statistics
Settings
Votes
Most liked content widget
BuddyPress Integration
Recording like and dislike actions in BuddyPress activity stream
BuddyPress notifications for authors when authenticated users like or dislike author's content
myCRED Like Button Hook

Documentation

The plugin is powered by Likebtn.com. The plugin is commercial and provides a 7-day TRIAL. After TRIAL ends your website is switched to the FREE plan and you can continue using FREE or upgrade.
  1. Install Like Button Voting & Rating plugin.
  2. Activate the plugin through the "Plugins" menu in WordPress.
  3. Open plugin Settings tab and click "Get Account Data".
  4. Register on LikeBtn.com, add your website to your account on LikeBtn.com and enter your LikeBtn.com account data on the plugin Settings tab.
  5. Open plugin Buttons tab, choose a post type and click "Enable Like Button".

Shortcodes (for using in content or theme templates)

In order to insert Like button inside a post/page content use the following shortcode: [likebtn]

You can pass Like button parameters like this:
[likebtn style="large" i18n_like="Yeah!"]

Use space to separate parameters, do not use commas or any other characters.

Do the following to generate a shortcode:
  1. Open plugin "Buttons" tab.
  2. Enable and configure the Like button for any post type.
  3. Scroll down and click "Get shortcode" link.



Button identifier parameter is used for statistics analysis. If identifier parameter is not specified, post ID is used.
If specifying custom identifier you will see button identifier in statistics and most liked content widget instead of post title. You also will be unable to sort posts by likes. Make sure to specify a unique identifier for each like button using identifier parameter, otherwise all the buttons will reflect the same number of likes.
Using shortcode in the template:
<?php echo do_shortcode('[likebtn theme="disk" dislike_enabled="false" white_label="true"]'); ?>
Upgrade your website to the tariff plan allowing to retrieve Statistics. On the plugin configuration page enable synchronization of likes into your website database.
Use the following shortcode:
[likebtn_most_liked title="Most Liked Content" number="5" order="dislikes" time_range="all" show_likes="0" show_dislikes="0" show_thumbnail="0" thumbnail_size="thumbnail" show_excerpt="0" show_date="0" entity_name="post,comment"]

Available entity_name values: post, page, attachment, revision, nav_menu_item, comment and custom post types.

You can also generate most liked content widget code:
  1. Go to "Appearance » Widgets".
  2. Add LikeBtn widget to the Widget Area.
  3. Click "Get shortcode" link.
Using shortcode in the template:
<?php echo do_shortcode('[likebtn_most_liked title="Most Liked Content" number="5" order="dislikes" time_range="all" show_likes="0" show_dislikes="0" show_thumbnail="0" thumbnail_size="thumbnail" show_excerpt="0" show_date="0" entity_name="post,comment"]'); ?>
Upgrade your website to the tariff plan allowing to retrieve Statistics. On the plugin configuration page enable synchronization of likes into your website database.
Use the following shortcode:
[likebtn_liked_by_user title="You Liked" number="5" order="dislikes" time_range="all" show_likes="0" show_dislikes="0" show_thumbnail="0" thumbnail_size="thumbnail" show_excerpt="0" show_date="0" entity_name="post,comment"]

Available entity_name values: post, page, attachment, revision, nav_menu_item, comment and custom post types.

You can also generate most liked content widget code:
  1. Go to "Appearance » Widgets".
  2. Add LikeBtn widget to the Widget Area.
  3. Click "Get shortcode" link.
Using shortcode in the template:
<?php echo do_shortcode('[likebtn_liked_by_user title="Most Liked Content" number="5" order="dislikes" time_range="all" show_likes="0" show_dislikes="0" show_thumbnail="0" thumbnail_size="thumbnail" show_excerpt="0" show_date="0" entity_name="post,comment"]'); ?>
Upgrade your website to the tariff plan allowing to retrieve Statistics. On the plugin configuration page enable synchronization of likes into your website database.
Use the following shortcode:
[likebtn_user_votes user_id="7" type="likes"]

  • type: likes, dislikes, total
  • user_id: if user_id is not set, votes number casted by the current authenticated user is displayed

Using shortcode in the template:
<?php echo do_shortcode('[likebtn_user_votes user_id="7" type="likes"'); ?>
Display the number of likes and dislikes for current post:
[likebtn_likes]
[likebtn_dislikes]
Display the number of likes and dislikes for the custom item with specified identifier:
[likebtn_likes identifier="my_item_1"]
[likebtn_dislikes identifier="my_item_1"]

Using shortcode in the template:
<?php echo do_shortcode('[likebtn_likes]'); ?>
<?php echo do_shortcode('[likebtn_dislikes]'); ?>
Shortcode to disable the Like button in a post/page: [likebtn_off]

Using shortcode in the template:
<?php echo do_shortcode('[likebtn_off]'); ?>

Sorting Content

Upgrade your website to the tariff plan allowing to retrieve Statistics. On the plugin configuration page enable synchronization of likes into your website database.
After enabling synchronization WordPress Like Button plugin adds 3 custom fields to posts:
  • Likes
  • Dislikes
  • Likes minus dislikes
You can sort posts in WordPress by custom fields values using query_posts() function. At first determine the template for inserting the code, it can be index.php, page.php, archive.php or any other depending on your needs and WordPress theme you are using. Then find the Loop in the template. Finally insert the query_posts() function call above the Loop:
<?php
    $args  = array(
        'orderby' => 'meta_value',
        'order' => 'DESC',
        'meta_query' => array(
            'relation' => 'OR',
             array(
                'key' => 'Likes',
                'compare' => 'NOT EXISTS',
                'type' => 'numeric'
             ),
             array(
                'key' => 'Likes',
                'compare' => 'EXISTS',
                'type' => 'numeric'
             )
         )
    );
    $args = array_merge( $args , $wp_query->query );
    query_posts($args);
?> 
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
In key parameter specify one of the 3 custom fields provided by LikeBtn plugin. In order parameter specify the desired sort order: DESC (descending), ASC (ascending).

Or if you are using WP_Query:
<?php
$query_args  = array(
    'post_type' => 'post',
    'orderby' => 'meta_value',
    'order' => 'DESC',
    'meta_query' => array(
        'relation' => 'OR',
         array(
            'key' => 'Likes',
            'compare' => 'NOT EXISTS',
            'type' => 'numeric'
         ),
         array(
            'key' => 'Likes',
            'compare' => 'EXISTS',
            'type' => 'numeric'
         )
     )
);
$loop = new WP_Query($query_args);
if ($loop->have_posts()):
    while($loop->have_posts()):
        $loop->the_post();
?>
        <a href="<?php the_permalink(); ?>">
            <div>
                <h3><?php echo the_title();?></h3>
                <p><?php echo the_content(); ?></p>
            </div>
        </a>
<?php
    endwhile;
endif;
?>
This technique requires basic programming skills. LikeBtn support team does not provide a personal development assistance for now. Feel free to hire a developer if you need a personal assistance.
  1. Upgrade your website to the tariff plan allowing to retrieve Statistics. On the plugin configuration page enable synchronization of likes into your website database.

    After enabling synchronization WordPress Like Button plugin adds 3 custom fields to posts:
    • Likes
    • Dislikes
    • Likes minus dislikes

  2. Create a new page, create a Custom page template and assign created Custom template to the page.
  3. If your custom page template does not have a posts loop, copy it from your current theme's index.php along with the pagination code.
  4. Insert the following code before the loop:
    <?php
        add_filter('posts_where', 'likebtn_loggedin_user_posts_where', 10, 2);
        $wp_query = new WP_Query();
        $wp_query->query('showposts=5' . '&paged='.$paged);
    ?>
  5. Here is an example of the resulting Custom page template (it will be different for each theme):
    <?php /* Template Name: ContentLikeByUser */ ?>
    
    <?php
    
    get_header(); ?>
    
        <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
            <?php
                add_filter('posts_where', 'likebtn_loggedin_user_posts_where', 10, 2);
                $wp_query = new WP_Query();
                $wp_query->query('showposts=5' . '&paged='.$paged);
            ?>
            <?php
            // Start the loop.
            while ( have_posts() ) : the_post();
    
                // Include the page content template.
                get_template_part( 'content', 'page' );
    
            // End the loop.
            endwhile;
    
            // Previous/next page navigation.
            the_posts_pagination( array(
                'prev_text'          => __( 'Previous page', 'twentyfifteen' ),
                'next_text'          => __( 'Next page', 'twentyfifteen' ),
                'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
            ) );
            ?>
    
            </main><!-- .site-main -->
        </div><!-- .content-area -->
    
    <?php get_footer(); ?>
    
  1. Upgrade your website to the tariff plan allowing to retrieve Statistics.
  2. Enable synchronization of likes into your WordPress database.
  3. Find the comments.php template of your current WordPress theme (for example /wp-content/themes/twentytwelve/comments.php)
  4. Add the second argument to all the calls of wp_list_comments() function in comments.php:
    // Before
    // wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ));
    
    // After
    $comments_sorted = likebtn_comments_sorted_by_likes();
    wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ), $comments_sorted );
    Use likebtn_comments_sorted_by_dislikes() function to sort comments by dislikes.
Do the following to add a new "Sort by likes" option to the WooCommerce Sort By dropdown:

  1. Upgrade your website to the tariff plan allowing to retrieve Statistics.
  2. Enable synchronization of likes into your WordPress database.
  3. Add the following code to your current theme's functions.php file:
    function likebtn_product_query($q) {
    
        if (!empty($q->orderby) && $q->orderby == 'likes' || (!empty($_GET['orderby']) && $_GET['orderby'] == "likes")) {
            $meta_query = $q->get('meta_query');
    
            array_unshift($meta_query, 
                array(
                    'relation' => 'OR',
                    array(
                        'key' => 'Likes',
                        'compare' => 'NOT EXISTS',
                        'type' => 'numeric',
                    ),
                    array(
                        'key' => 'Likes',
                        'compare' => 'EXISTS',
                        'type' => 'numeric',
                    )
                )
            );
    
            $q->set( 'meta_query', $meta_query );
            $q->set( 'orderby', 'meta_value' );
            $q->set( 'order', 'DESC' );
        }
    }
    
    add_action( 'woocommerce_product_query', 'likebtn_product_query' );
    
    function likebtn_woocommerce_catalog_orderby($sortby) {
        $sortby['likes'] = __( 'Sort by likes', 'woocommerce' );
    
        return $sortby;
    }
    
    add_filter( 'woocommerce_default_catalog_orderby_options', 'likebtn_woocommerce_catalog_orderby' );
    add_filter( 'woocommerce_catalog_orderby', 'likebtn_woocommerce_catalog_orderby' );

Custom Templates

If you want to override the default template do the following:
  1. Create a likebtn-like-button folder inside your current theme directory, for example /wp-content/themes/twentytwelve/likebtn-like-button.
  2. Copy /wp-content/plugins/likebtn-like-button/templates/most-liked-widget.php to the newly created likebtn-like-button folder.
  3. Edit /wp-content/plugins/likebtn-like-button/templates/most-liked-widget.php template.
If you want to override the default template do the following:
  1. Create a likebtn-like-button folder inside your current theme directory, for example /wp-content/themes/twentytwelve/likebtn-like-button.
  2. Copy /wp-content/plugins/likebtn-like-button/templates/liked-by-user-widget.php to the newly created likebtn-like-button folder.
  3. Edit /wp-content/plugins/likebtn-like-button/templates/liked-by-user-widget.php template.
  1. Create a likebtn-like-button folder inside your current theme directory, for example /wp-content/themes/twentytwelve/likebtn-like-button.
  2. Copy /wp-content/plugins/likebtn-like-button/templates/like-box.php to the newly created likebtn-like-button folder.
  3. Edit /wp-content/plugins/likebtn-like-button/templates/like-box.php template.

Other

If you want to add the Like Button into the Text Widget (in a custom widget area of the post, for example) do not add LikeBtn HTML-code directly into the Text Widget, do the following instead:
  1. Install and activate LikeBtn WordPress plugin.
  2. Install and activate the Shortcodes in Sidebar Widgets plugin.
  3. Insert LikeBtn shortcode into the Text Widget.
This method of inserting the Like button is not recommended. Please use plugin admin panel or shortcodes to insert the button.

If inserting Like button using HTML-code you will see button identifier in statistics and most liked content widget instead of post title. You also will be unable to sort posts by likes.
Generate Like button HTML-code and insert into the post or WordPress template.

Make sure to specify a unique identifier for each like button using identifier parameter, otherwise all the buttons will reflect the same number of likes. Button identifier parameter is used for statistics analysis.
The identifer parameter in WordPress LikeBtn plugin has the following structure: Post type + _ + Post ID

Examples:
  • post_1
  • page_7
So if you need to insert the LikeBtn HTML-code directly into WordPress post template, you can specify identifier parameter as follows: data-identifier="post_<?php the_ID()?>"
Upgrade your website to the tariff plan allowing to retrieve Statistics. On the plugin configuration page enable synchronization of likes into your website database.
To display number of likes and dislikes in the posts list, insert the following code:
<?php $post_custom = get_post_custom( get_the_ID() ); ?>
Likes: <?php echo (int)$post_custom['Likes'][0]; ?> |
Dislikes: <?php echo (int)$post_custom['Dislikes'][0]; ?>
into the posts loop in the index.php, page.php, home.php or any other template depending on the WordPress theme you are using (for example /wp-content/themes/twentytwelve/index.php):
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>

<?php /* Get and display number of likes and dislikes */ ?>
<?php $post_custom = get_post_custom( get_the_ID() ); ?>
Likes: <?php echo (int)$post_custom['Likes'][0]; ?> |
Dislikes: <?php echo (int)$post_custom['Dislikes'][0]; ?>
<?php endwhile; ?>
To display number of likes and dislikes in excerpts and full posts, insert the following code into the content.php or any other template depending on the WordPress theme you are using (for example /wp-content/themes/twentytwelve/content.php):
<?php $post_custom = get_post_custom( get_the_ID() ); ?>
Likes: <?php echo (int)$post_custom['Likes'][0]; ?> |
Dislikes: <?php echo (int)$post_custom['Dislikes'][0]; ?>
You can use LikeBtn plugin in a multisite networks. Add each website of the network as a separate website to your account on Websites page. If using path-based (sub-directories) multisite network please make sure to specify the "Subdirectory" when adding each website. See bulk discount pricing.
For example if you want to redirect visitor when visitor votes for the post with ID=12:

  1. Add the following custom JavaScript code on Settings tab:
    function my_likebtn_callback(event) {
        if (event.type == "likebtn.like" && event.settings.identifier == "post_12") {
            window.location.href = 'https://likebtn.com';
        }
    }
  2. Enter the JavaScript callback function name on Events subtab of Buttons tab: my_likebtn_callback
Add the following code to your current theme's functions.php file:

/**
 * Action triggered when visitor votes.
 * 
 * args:
 * [identifier] - Identifier of the Like button (Read more: https://likebtn.com/en/wordpress-like-button-plugin#identifier)
 * [entity_name] - The Like button code of the entity to which Like button is attached: post, page, comment, attachment, user, product, bp_activity_post, bp_activity_update, bp_activity_comment, bp_activity_topic, bp_member, bbp_post, bbp_user, um_user. If the Like button is added using HTML-code or shortcode and not attached to any WordPress entity entity_name is equals to: custom_item
 * [entity_id] - ID of the WordPress entity to which the Like button is connected.
 * [type] - Type of the vote: 1 - like, -1 - dislike, 0 - vote canceled
 * [act] - The action applied to the vote: a - new vote registered, u - voter changed his opinion from like to dislike and vice versa, r - voter canceled his previous vote. 
 * [user_id] - ID of the voting user, can be empty if anonymous visitor is voting (Example: 3)
 * [ip] - IP-address of the voter (Example: 75.19.150.29)
 * [lat] - Lattitude of the voter (Example: 65,3619)
 * [lng] - Longitude of the voter (Example: 27,393101)
 * [created_at] - Date and time of the vote (Example: 2016-11-09 01:48:57)
 */
function likebtn_vote_action($args)
{
    // Get ID of the author of the entity for which visitor just voted
    $author_id = _likebtn_get_author_id($args['entity_name'], $args['entity_id']);
    if (!$author_id || $author_id == $args['user_id']) {
        return;
    }

    $author_data = get_userdata($author_id);
    if (!$author_data || empty($author_data->user_email)) {
        return;
    }

    $type_title = '';
    if ($args['type'] == 1) {
        $type_title = 'like';
    } elseif ($args['type'] == -1) {
        $type_title = 'dislike';
    } else {
        return;
    }

    $entity_name_title = mb_strtolower(_likebtn_get_entity_name_title($args['entity_name'], true));
    $entity_title = _likebtn_get_entity_title($args['entity_name'], $args['entity_id']);
    $entity_url = _likebtn_get_entity_url($args['entity_name'], $args['entity_id']);

    // Adjust the block of below according your needs
    $domain = parse_url(get_home_url(), PHP_URL_HOST);
    $to = $author_data->user_email;
    $subject = "Your ".$entity_name_title." received a {$type_title} at {$domain}!";
    $from = "noreply@".$domain;
    $reply_to = "postmaster@".$domain;
    $body = "
        Hi {$author_data->display_name}!<br/><br/>
        Congratulations! Your <a href=\"{$entity_url}\">{$entity_title}</a> {$entity_name_title} has just received a <strong>{$type_title}</strong>.<br/><br/>
        <span style=\"color:#808080\">--<br/>
        With best wishes,<br/>
        {$domain}</span>
    ";

    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=\"utf-8\"\r\n";
    $headers .= 'From: '.$from."\r\n";
    if ($reply_to) {
        $headers .= "Reply-To: ".$reply_to."\r\n";
    }
    $subject = '=?UTF-8?B?'.base64_encode($subject).'?=';

    return mail($to, $subject, $body, $headers);
}

add_action('likebtn_vote', 'likebtn_vote_action');
  1. Install the myCRED plugin.
  2. Configure "Points for Getting a Content Like" for comments/posts in the myCRED Hooks.
  3. Use the following shortcode to display number of author likes in a page:
    <?php echo do_shortcode( '[mycred_my_balance user_id="'.$post->post_author.'" balance_el="i"]' ); ?>
    in a post:
    <?php echo do_shortcode( '[mycred_my_balance user_id="'.the_author_meta('ID').'" balance_el="i"]' ); ?>
  4. Use myCRED Leaderboard widget to display top authors.

General Questions

Votes are stored in the LikeBtn system and during synchronization plugin saves them in the Custom fields, which are stored in postmeta, commentmeta, usermeta, bp_xprofile_meta and bp_activity_meta WordPress tables.

Troubleshooting

If you are enabling Like button not through the plugin dashboard but using a shortcode or generated HTML-code, make sure to specify a unique identifier for each like button using identifier parameter.
  1. Install Advanced Excerpt plugin.
  2. Go to "Excerpt" under the "Settings" menu of the plugin and check "Don't remove any markup" checkbox.
If it did not help, find your theme's excerpt post template and replace custom function showing excerpt with get_the_excerpt() function. For example PinThis theme in /wp-content/themes/PinThis/pinbox.php is using custom pinthis_excerpt() function to show post excerpt. Replacing it with get_the_excerpt() does the trick.
Some WordPress themes (e.g Bridge Theme) are not using standard WordPress function to display posts. In this case you have to insert Like button into the theme post template using shortcode.
If you are inserting the LikeBtn code directly into template or using the shortcode, you need to execute the following JavaScript after loading items using AJAX:
if (typeof(LikeBtn) != "undefined") {
    LikeBtn.init();
}
If it is happenning on a single post page try installing WP Open Graph plugin.

If it is happenning on a page with a list of posts then there is no way to make Facebook fetch image and title of a particular post.

Integration with Other Plugins

In paged-post-slider.php file of the Paged Post Slider plugin replace $ppscontent .= wpautop($post->post_content); with the following code:
remove_filter('the_content', 'paged_post_the_content_filter');
$ppscontent .= apply_filters('the_content', $post->post_content);

WordPress Themes Not Fully Supporting the Like Button

Theme Does not display the Like button in...
Thesis Comments
Multinews Post excerpts
Flatly Post excerpts

Testimonials

Just mention @likebtn in Twitter and we will add your testimonial

Referral Program

Earn Money With LikeBtn!

Place our referral link or a banner on a website, get rewarded with 25% of all payments made by referred members (including all his future payments for renewals of subscription plans).

Referral rewards are paid to you via PayPal at the end of each month. What if I don't have a PayPal account?

Start Earning Now



Didn't find what you need? Visit our FAQ