• Hi,

    Is it still possible to sort the posts by ratings (_kksr_ratings) in the widget? I am using the 2.4 version of the plugin.

    At the moment it seems like i can only sort by casts or by average (according to the SQL query in index.php.

    Is there a possiblity to order by _kksr_ratings instead? I am running a competition where the top score (ratings) wins. Neither of casts or average sorting will make the top scores list in the right order, but $ratings would do it beautifully.

    Thanks in advance for your help!

    http://wordpress.org/plugins/kk-star-ratings/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Kamal Khan

    (@bhittani)

    _kksr_ratings is the total ratings in number added up. so average would determine the top rated post in this case.

    Thread Starter simonswiss

    (@simonswiss)

    I thought _kksr_ratings is the average rating multiplied by the number of votes (casts).

    Example: one post has 10 votes with an average of 4.5 –> Rating = 45

    That’s the value i use to measure the score (quality and popularity) and i can display the value with no problem, i just can’t sort it in the right way.

    Example:

    If 1 post has 5 votes and an average of 5 stars, the score it gets (_kksr_ratings) is 25.

    Another post has 10 votes and average of 4 –> _kksr_ratings = 40.

    In the competition set up on my site, the post with 40 points should win and therefore be listed on top. But the average is lower and therefore it displays under the 25 pts post.

    Makes sense?

    Since the value _kksr_ratings is stored, isnt’t it possible to order the posts by this value?

    Plugin Contributor Kamal Khan

    (@bhittani)

    You can do that by querying the WP Post object and setting the _kksr_ratings custom field criteria.

    Thread Starter simonswiss

    (@simonswiss)

    That’s what i have been trying to do for a while, but i cannot figure out what the code should be and where to place it.

    If you could guide me in the right direction i would be very grateful. 🙂

    Plugin Contributor Kamal Khan

    (@bhittani)

    <?php
    
    // The Query
    $the_query = new WP_Query(array( 'meta_key' => '_kksr_ratings', 'orderby' => 'meta_value_num', 'order' => 'DESC'));
    
    // The Loop
    if ( $the_query->have_posts() ) {
    	while ( $the_query->have_posts() ) {
    		$the_query->the_post();
    		echo '<li>' . get_the_title() . '</li>';
    	}
    } else {
    	// no posts found
    }
    /* Restore original Post Data */
    wp_reset_postdata();
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sort widget by ratings (avg * casts) in 2.4’ is closed to new replies.