Make your site look appealing to the visitors on search engine results pages!
Boost search engine rankings!
Increase clicks!
[likebtn]
[likebtn style="large" i18n_like="Yeah!"]
identifier
parameter is used for statistics analysis.
If identifier
parameter is not specified, post ID is used. identifier
parameter, otherwise all the buttons will reflect the same number of likes. <?php echo do_shortcode('[likebtn theme="disk" dislike_enabled="false" white_label="true"]'); ?>
[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"]
entity_name
values: post, page, attachment, revision, nav_menu_item, comment and custom post types.<?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"]'); ?>
[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"]
entity_name
values: post, page, attachment, revision, nav_menu_item, comment and custom post types.<?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"]'); ?>
[likebtn_user_votes user_id="7" type="likes"]
<?php echo do_shortcode('[likebtn_user_votes user_id="7" type="likes"'); ?>
[likebtn_likes]
[likebtn_dislikes]
identifier
:
[likebtn_likes identifier="my_item_1"]
[likebtn_dislikes identifier="my_item_1"]
<?php echo do_shortcode('[likebtn_likes]'); ?>
<?php echo do_shortcode('[likebtn_dislikes]'); ?>
[likebtn_off]
<?php echo do_shortcode('[likebtn_off]'); ?>
[likebtn_category_likes]
[likebtn_category_likes category_id="7"]
<?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; ?>
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). <?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;
?>
index.php
along with the pagination code.
<?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 /* 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(); ?>
comments.php
template of your current WordPress theme (for example /wp-content/themes/twentytwelve/comments.php
)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 );
likebtn_comments_sorted_by_dislikes()
function to sort comments by dislikes. 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' );
likebtn-like-button
folder inside your current theme directory, for example /wp-content/themes/twentytwelve/likebtn-like-button
./wp-content/plugins/likebtn-like-button/templates/most-liked-widget.php
to the newly created likebtn-like-button
folder./wp-content/plugins/likebtn-like-button/templates/most-liked-widget.php
template.likebtn-like-button
folder inside your current theme directory, for example /wp-content/themes/twentytwelve/likebtn-like-button
./wp-content/plugins/likebtn-like-button/templates/liked-by-user-widget.php
to the newly created likebtn-like-button
folder./wp-content/plugins/likebtn-like-button/templates/liked-by-user-widget.php
template.likebtn-like-button
folder inside your current theme directory, for example /wp-content/themes/twentytwelve/likebtn-like-button
./wp-content/plugins/likebtn-like-button/templates/like-box.php
to the newly created likebtn-like-button
folder./wp-content/plugins/likebtn-like-button/templates/like-box.php
template.identifier
parameter, otherwise all the buttons will reflect the same number of likes. Button identifier
parameter is used for statistics analysis. data-identifier="post_<?php the_ID()?>"
<?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]; ?>
/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; ?>
/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]; ?>
function my_likebtn_callback(event) {
if (event.type == "likebtn.like" && event.settings.identifier == "post_12") {
window.location.href = 'https://likebtn.com';
}
}
my_likebtn_callback
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');
<?php echo do_shortcode( '[mycred_my_balance user_id="'.$post->post_author.'" balance_el="i"]' ); ?>
<?php echo do_shortcode( '[mycred_my_balance user_id="'.the_author_meta('ID').'" balance_el="i"]' ); ?>
likebtn_item
, likebtn_vote
tables and in custom fields. postmeta
, commentmeta
, usermeta
, bp_xprofile_meta
and bp_activity_meta
WordPress tables. identifier
parameter.
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. if (typeof(LikeBtn) != "undefined") {
LikeBtn.init();
}
$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);
Theme | Does not display the Like button in... |
---|---|
Thesis | Comments |
Multinews | Post excerpts |
Flatly | Post excerpts |
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?