Title: Showposts being &#8220;odd:
Last modified: August 19, 2016

---

# Showposts being “odd:

 *  [davidswain](https://wordpress.org/support/users/davidswain/)
 * (@davidswain)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/showposts-being-odd/)
 * Hi
 * I have this function in my theme:
 *     ```
       //my functions
       function getThumbs($amount) {
   
       	echo "<div id=\"media-gallery\">\n";
       	echo "<h2>Media Gallery</h2>\n";
       	echo "<ul>\n";
   
        			query_posts('showposts=' . $amount . '&cat=1,6&orderby=rand');
   
       				while (have_posts()) : the_post(); 
   
       					$category = get_the_category(); 
   
       					if ( in_category('6') ) {
       						$catnicename = "showreel";
       						$custom_fields = get_post_custom();
       				     	$images = $custom_fields['showreel_thumbnail'];
       					} else {
       						$catnicename = $category[0]->category_nicename;
       						$custom_fields = get_post_custom();
       				     	$images = $custom_fields['image_url'];
       					}
       				  		  if(is_array($images))	{
       				    		foreach ( $images as  $value )
   
       							if ( in_category('6') ) {
       										echo "<li><a href=\"";
       										the_permalink();
       										echo "\"><img src=\"";
       										echo str_replace(".jpg", ".gif", $value);
       										echo "\" alt=\"" . get_the_title() . "\" /></a></li>\n";
       							} else {
       									echo "<li><a href=\"";
       									the_permalink();
       									echo "\"><img src=\"/image/galleries/";
       									echo $catnicename;
       									if (!isset($listOnly)){
       										echo "/frontpage/";
       									} else {
       										echo "/largeThumbs/";
       									}
       									echo $value;
       									echo "\" alt=\"" . get_the_title() . "\" /></a></li>\n";
       							}
   
       							}
       				endwhile;
       		echo "</ul>\n";
       			echo "</div>";
       }
       ```
   
 * Which i call using:
 * `<?php if (function_exists('getThumbs')) getThumbs(55); ?>`
 * It behaves… oddly, usually returning 55 posts, but sometimes 56!
 * Any ideas why?
 * Can be seen here: [http://davidswain.co.uk](http://davidswain.co.uk), click refresh
   a few times.. Doesnt do it on the localhost, just the webserver!

Viewing 1 replies (of 1 total)

 *  Thread Starter [davidswain](https://wordpress.org/support/users/davidswain/)
 * (@davidswain)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/showposts-being-odd/#post-1094241)
 * anyone?

Viewing 1 replies (of 1 total)

The topic ‘Showposts being “odd:’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [davidswain](https://wordpress.org/support/users/davidswain/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/showposts-being-odd/#post-1094241)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
