Display voting stats on frontend

Hi,

There is a page in the admin for the Post Voting plugin that displays total votes, votes up and votes down (https://premium.wpmudev.org/wp-content/uploads/2011/05/Post-Voting-Voting-Stats.png). I would like to be able to show this data on the front end.

Currently I am using a custom function (https://codepad.co/snippet/KzN9rAbN) to output the title of the post and the total vote count, but I don't know how to get the votes up and votes down. Can anybody point me in the right direction?

Thanks

  • Rupok

    Hi Xavier,

    I just checked how up votes and down votes are stored in database. I found that each vote is added in the database as a row with timestamp and post ID. Positives have value "1" and negatives have value "-1". Please check the attached screenshot for reference.

    So you can programmatically count the number of rows with value "1" in "vote" column for specific post ID to get the total number of up votes and count the "-1" for down votes. In this way, you can show number of votes up and votes down.

    If you need the exact code for doing this, this will require advanced custom code and I'm afraid, I can't do this in 5 - 10 minutes. If this was something which can be done in 10 minutes, I'd love to do that for you. But as this will take longer, this gets beyond our support scope and falls in the custom job section. You can get full details of our policy regarding support vs. custom jobs here: https://premium.wpmudev.org/manuals/using-wpmu-dev/support-vs-custom-development/

    However, you can always hire a developer for you from our Jobs Section. Please note, developers found in our Jobs Section are not associated with us in any way. So communicate with them well before you make any payments to them.

    Please let us know if you have any confusion. We will be glad to help.

    Have a nice day. Cheers!
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.