Forums

GD Star Rating
[resolved] Incorrect ratings showing up for each post (4 posts)

  1. choazie
    Member
    Posted 1 year ago #

    Hi there

    I have a few hundred posts on my site for which I have activated the articles star ratings. The stars are showing up for each post but it seems to be displaying random star ratings for each post. I.e. each post is displaying incorrect star ratings, like the plugin is not assigning the correct star rating for each post.

    Here's an example of a post, if you refresh a few times you'll get different star ratings each time:

    http://www.ratethishunk.com/hunk-122/ semi NSFV (if you're a guy, I apologize for making you look at that :))

    According to the plugin's statistics, this post has not been rated at all, but it's still showing star ratings.

    Any idea what's going on here?

    Here's the plugin settings under Article: http://i53.tinypic.com/igmas1.png

    Here's the single.php code in which the star ratings is appearing:

    <?php if (have_posts()) : ?>
    
    				<?php while (have_posts()) : the_post(); ?>
    				<div class="full" align="center">
    
    		<br />
    
    				<?php $posts = get_posts('orderby=rand&numberposts=1'); foreach($posts as $post) { ?>
    				<a href="<?php the_permalink(); ?>#hunk" id="hunk" class="button" title="<?php the_title(); ?>">generate a random hunk</a>
    
    				<?php } ?>
    
    		<br /><br />
    
    				<div class="padding" align="center">
    				<div align="center">
    					<?php the_content() ?>
    				</div>
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
  2. Milan Petrovic
    Member
    Posted 1 year ago #

    Most likely $posts block you added in the loop is interfering. This is not the way to use nested loops (even so the other one is not really a loop).

  3. choazie
    Member
    Posted 1 year ago #

    Thanks for your reply!

    Do you have a suggestion as to how to change the code for it to work properly?

    Much appreciation for your help.

  4. choazie
    Member
    Posted 1 year ago #

    I managed to solve this by using a different $posts block to generate the random post.

    <?php
    $randomPost = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY rand() LIMIT 1");
    echo '<a class="button" href="'.$randomPost.'">generate a random hunk</a>';
    ?>

    Thanks for putting me on the right track!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic