Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Lester Chan

    (@gamerz)

    Thread Starter Doug

    (@nicoblog)

    I see Thanks!!!
    It worked, but needs some tweaking to display the real top posts.

    1. “Sticky” posts come up first, i have 3 posts on sticky and they are the 1st, 2nd and 3rd result. i would want them to appear according to rating as well.

    2. I’d need it to show posts that have at least 10 votes or so because posts with 1 vote and 5.00 score come up first while posts with 100 votes and 4.95 score come up second (or page 2-10).

    I hope it’s possible to achieve? Sorry for trouble.

    Plugin Author Lester Chan

    (@gamerz)

    1. Not too sure, I didn’t test it with sticky post
    2. Not too sure as well, since I have not tried it, you will have to play around with the http://codex.ww.wp.xz.cn/Class_Reference/WP_Query or http://codex.ww.wp.xz.cn/Class_Reference/WP_Meta_Query. But I think it should be possible, maybe something like:

    $args = array(
    	'meta_key'   => 'ratings_average',
    	'orderby'    => 'meta_value_num',
    	'order'      => 'DESC',
    	'meta_query' => array(
    		array(
    			'key'     => 'ratings_users',
    			'value'   => 10,
    			'compare' => '>=',
    		),
    	),
    );
    $query = new WP_Query( $args );

    (note that all this are not within my support scope, so you have to figure it out yourself or hire a developer)

    Thread Starter Doug

    (@nicoblog)

    I know sorry to ask you but you know the plugin more than anyone and if someone can pull it off it’s you 😀
    Sorry for trouble.

    Hello nicoblog

    2. I’d need it to show posts that have at least 10 votes or so because posts with 1 vote and 5.00 score come up first while posts with 100 votes and 4.95 score come up second (or page 2-10).

    I hope it’s possible to achieve? Sorry for trouble

    In the wp-postratings.php
    Search

    function ratings_highest_where($content) {
    	$ratings_max = intval(get_option('postratings_max'));
    	$ratings_custom = intval(get_option('postratings_customrating'));
    	if($ratings_custom && $ratings_max == 2) {
    		$content .= " AND t1.meta_key = 'ratings_score' AND t2.meta_key = 'ratings_users'= t2.meta_key = 'ratings_users'";
    	} else {
    		$content .= " AND t1.meta_key = 'ratings_average' AND t2.meta_key = 'ratings_users' = t2.meta_key = 'ratings_users'";
    	}
    	return $content;
    }

    Replace with

    function ratings_highest_where($content) {
    	$ratings_max = intval(get_option('postratings_max'));
    	$ratings_custom = intval(get_option('postratings_customrating'));
    	if($ratings_custom && $ratings_max == 2) {
    		$content .= " AND t1.meta_key = 'ratings_score' AND t2.meta_key = 'ratings_users' AND t2.meta_value >= 10";
    	} else {
    		$content .= " AND t1.meta_key = 'ratings_average' AND t2.meta_key = 'ratings_users' AND t2.meta_value >= 10";
    	}
    	return $content;
    }

    The code AND t2.meta_value >= 10 ensures that only Posts are displayed with minimum 10 Votes.

    best regards R.F.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Display posts by rating on the loop’ is closed to new replies.