• James

    (@thepianocian)


    I saw that a previous post here mentioned using

    $total = get_post_meta($post_id, ‘_thumbs_rating_up’, true) + get_post_meta($post_id, ‘_thumbs_rating_down’, true);

    to get the sum of the votes to display. How do you do this?

    My goal is to have the sum of the votes be displayed on each post. I have the plugin enabled to show the vote buttons on every post, but they show only the thumbs up total and the thumbs down total, but not the sum of the two.

Viewing 1 replies (of 1 total)
  • Plugin Author Ricard Torres

    (@quicoto)

    James,

    Yeah what you got there seems to be correct.

    I just copied parts of the source dode and made the sum afterwards:

    
    $thumbs_rating_up_count = get_post_meta(get_the_ID(), '_thumbs_rating_up', true) != '' ? get_post_meta(get_the_ID(), '_thumbs_rating_up', true) : '0';
    
    $thumbs_rating_down_count = get_post_meta(get_the_ID(), '_thumbs_rating_down', true) != '' ? get_post_meta(get_the_ID(), '_thumbs_rating_down', true) : '0';
    
    echo $thumbs_rating_down_count + $thumbs_rating_up_count;
    

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying sum of votes on each post’ is closed to new replies.