WordPress.org

Ready to get started?Download WordPress

Forums

WTI Like Post
how to show like/dislike in one number? (3 posts)

  1. radiofranky
    Member
    Posted 1 year ago #

    Hi,
    Currently this plugin display one number for like and one for dislike.
    I was wondering if there is a way to display only one number for both like and dislike. Something like "like" 4 "dislike"
    if another dislike was clicked, it will show "like" 3 "dislike".

    thanks very much

    http://wordpress.org/extend/plugins/wti-like-post/

  2. radiofranky
    Member
    Posted 1 year ago #

    Hi,
    I was wondering if you could point me out where do you print out the like and dislike numbers. I can quickly do a subtraction of both and print a new number out. This would resolve my question.

    thanks

  3. radiofranky
    Member
    Posted 1 year ago #

    this is what I have. However, the unlike still showing "+" in front the unlike value. Thanks

    global $wpdb;
         $show_symbols = get_option('wti_like_post_show_symbols');
         $wti_unlike_count = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post WHERE post_id = '$post_id' AND value <= 0");
         $wti_like_count = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post WHERE post_id = '$post_id' AND value >= 0");
         if(!$wti_like_count) {
    		$wti_like_count = 0;
         }
    
    	 if(!$wti_unlike_count) {
    		$wti_unlike_count = 0;
         } else {
    		if($show_symbols) {$wti_unlike_count;
    		} else {
    			$wti_unlike_count;
    		}
         }
    
    	 if($wti_like_count != $wti_unlike_count){
    
       if($wti_like_count > $wti_unlike_count){$wti_like_final = $wti_like_count - $wti_unlike_count;$wti_like_final = "+" . $wti_like_final;}
       else{$wti_like_final = $wti_unlike_count - $wti_like_count;$wti_like_final = "-" . $wti_like_final;}
       }
       else
    
       {$wti_like_final = '0'; }
    
    	  return $wti_like_final;

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.