Title: [Plugin: NextGEN Gallery Voting] Script returns 3 same pictures
Last modified: August 20, 2016

---

# [Plugin: NextGEN Gallery Voting] Script returns 3 same pictures

 *  [crazytapczan](https://wordpress.org/support/users/crazytapczan/)
 * (@crazytapczan)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-voting-script-returns-3-same-pictures/)
 * Hi there!
 * I’m using function wrote by shauno (showing images ordered by vote) and this 
   function is there:
 *     ```
       function shaunos_awsome_top_images_i_should_really_consider_donating($limit=10) {
       	global $wpdb, $nggdb;
       	$qry = 'SELECT pid, SUM(vote) AS total, AVG(vote) AS avg, MIN(vote) AS min, MAX(vote) AS max, COUNT(vote) AS num'; //yes, no joins for now. performance isnt an issue (i hope...)
       	$qry .= ' FROM '.$wpdb->prefix.'nggv_votes';
       	$qry .= ' WHERE';
       	$qry .= ' pid > 0';
       	$qry .= ' GROUP BY pid';
       	$qry .= ' ORDER BY avg DESC';
       	$qry .= ' LIMIT 0, '.$limit;
   
       	$list = $wpdb->get_results($qry);
   
       	foreach ($list as $key=>$val) {
       		$val->image = nggdb::find_image($val->pid);
   
       		/*
       		//Uncomment this amazing piece of code to see all the magical attributes provided, free of charge, by NextGEN. Radical bro.
       		print("<pre style='font-family:verdana;font-size:13;color:#000;z-index:99999;background:#ccc;'>");
       		print_r($val);
       		print("</pre>");
       		*/
   
       		echo "<a href='";
       		echo $val->image->imageURL;
       		echo "' title='";
       		echo $val->image->description;
       		echo "'";
       		echo $val->image->thumbcode;
       		echo "'><img title='";
       		echo $val->image->alttext;
       		echo "' alt='";
       		echo $val->image->alttext;
       		echo "' src='";
       		echo $val->image->thumbURL;
       		echo "'";
       		echo $val->image->size;
       		echo " /></a>";
       	}
       }
       ```
   
 * If if call function like this `<?php shaunos_awsome_top_images_i_should_really_consider_donating?
   >` in the view/singlepic.php then it returns me the same pictures for three times(
   if i added 3 pictures earlier, for example if I add four pictures – then script
   will return four times same pictures). Script doesn’t return on my post single
   pictures. It returns me three times same pictures i the same sequence (order 
   by avg). I want that it will return me single images, not duplicated. What’s 
   problem with this script? I don’t use gallery. I wrote post tags responsible 
   for show single images in my post and i want show images in normal post, not 
   in file responsible for template.
 * I’m also tried to copy code from function nggv_admin_top_rated_images in ngg-
   voting.php but it’s the same problem. In admin panel images are single, but on
   my post images are duplicated. I don’t understand it.
 * Sorry for my bad english, but i hope that is undestandable for you.
 * I will be grateful for your help 🙂
 * Best regards,
    crazytapczan
 * _[ Please do not bump, it’s [not permitted here](http://codex.wordpress.org/Forum_Welcome#No_Bumping).]_

The topic ‘[Plugin: NextGEN Gallery Voting] Script returns 3 same pictures’ is closed
to new replies.

## Tags

 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [nggallery](https://wordpress.org/support/topic-tag/nggallery/)
 * [vote](https://wordpress.org/support/topic-tag/vote/)

 * 0 replies
 * 1 participant
 * Last reply from: [crazytapczan](https://wordpress.org/support/users/crazytapczan/)
 * Last activity: [13 years, 12 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-voting-script-returns-3-same-pictures/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
