Title: Listing Thumbnails Without Repeat
Last modified: August 20, 2016

---

# Listing Thumbnails Without Repeat

 *  [Ben](https://wordpress.org/support/users/communicatorsinaction/)
 * (@communicatorsinaction)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/listing-thumbnails-without-repeat/)
 * Howdy,
 * Semi-new guy here. I had a question about listing thumbnails. I’m running the
   latest version of WP (3.4.1) and am using a theme from Theme Trust (Uber). However,
   I am building a custom area to display articles on the home page. I have several
   boxes with the title and excerpt over an opaque background, and have it set up
   so that a background image can display behind all of it. I have managed to automate
   the retrieval of the excerpt and title, but am having trouble forcing ordered
   retrieval of the thumbnail and placing it as a background image in the box of
   its respective post.
 * At first, it used the last thumbnail as the background image in each box, but
   with the code below (which I thought would fix my problem) it instead displays
   the second to last thumbnail in each box. And the more times I put `$image_url[
   0]` inside of my array, the further back in the thumbnails it goes (you can see
   the current state of this situation [on the test site I’m running](http://dev.communicatorsinaction.com/)).
   The code is applied inside the loop on my home page template file, and is as 
   follows:
 *     ```
       <?php while (have_posts()) : the_post(); ?>
       		<div <?php post_class('small'); ?>>
       		<?php
          			$image_id = get_post_thumbnail_id();
          			$image_url = wp_get_attachment_image_src($image_id,'cia_post_thumb_ra_big');
       			array_push($array_image_url,$image_url[0]);
       		?>
       		<?php require 'ra.php'; ?>
       		</div>
       	<?php endwhile; ?>
       ```
   
 * Then inside of my CSS (ra.php), as my `background-image:`, I am placing `url(
   <?php echo $array_image_url[0]; ?>)`. And then for each successive box ID (eight
   in all) I am replacing the `0` with `1`, `2`, and so on. This was what I thought
   would solve my problem. Am I misunderstanding arrays or array_push? Is there 
   a better way to solve my problem? Is my syntax off? I have tried several things,
   but none of them have worked so far.
 * Any help on this issue would be much appreciated, as my experience with PHP and
   CSS is very limited.
 * Thanks!
    Ben

The topic ‘Listing Thumbnails Without Repeat’ is closed to new replies.

## Tags

 * ["background-image"](https://wordpress.org/support/topic-tag/background-image/)
 * [css](https://wordpress.org/support/topic-tag/css/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)
 * [thumbnail](https://wordpress.org/support/topic-tag/thumbnail/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Ben](https://wordpress.org/support/users/communicatorsinaction/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/listing-thumbnails-without-repeat/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
