Order by Most to Least Votes?

*UPDATE*I need a solution ASAP so I'm willing to pay someone for assistance. Thanks.

Here's what I'm doing:

I'm using WP_Query to display a list of posts within a custom post type with a specific taxonomy. I'm showing post title, a few custom fields and the vote up button, vote down button and the vote results for each post. That all works beautifully.

Here's what I need:

I noticed there is a meta_value_num orderby parameter I can add to my WP_Query array that will display the posts by the numbers in that meta field. Does this plugin store the votes in a meta filed? If so what is it called? Hopefully this is the case.

If this is not possible, what do I need to add to my query to get the posts to display form highest to lowest number of votes?

Here is my query:

$query = new WP_Query( array( 'post_type' => 'build', 'posts_per_page' => -1, 'build_type' => 'barbarian') );
while ( $query->have_posts() ) : $query->the_post();
  • Arun Basil Lal
    • New Recruit

    Hello Jason,

    Welcome to WPMU Dev!

    You do not have to pay anyone for this, when you paid for the membership you paid for this already. And am gonna make it up to you and prove it to you how a WPMU Dev! membership is like having your own development team :slight_smile:

    So I had a discussion with the developer and he pointed out couple of things.

    - First, the plugin doesn't uses the postmeta to store the number of votes, its in a separate table of its own (for network support).
    - Checkout this file class_wdpv_model.php in the /lib/ folder. You will find a function get_popular_on_current_site inside this. This has been used to create the most rated widget and the code can be found here: class_wpdv_widget_popular.php

    I suppose the code from this widget is exactly what you need and you look like someone who can handle this, yes? If you cannot figure this out, just let me know and I will get the developer on board and get it resolved.

    Let me know how it goes, am keeping an eye on this thread.

    Arun Basil Lal

  • jasonmanheim
    • New Recruit


    Thanks for the reply and letting me know great the WPMU Dev membership is. :slight_smile:

    I'll look into what you suggested but in the meantime I got what I needed by setting a "total_votes" custom field set to 0 during the form submission and then if the post is voted on it updates that number and displays the posts using the meta_value_num orderby parameter.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.