Jump to content

Help using loop and image array to set thumbnail image...


biagio111

Recommended Posts

Hello everyone. First post here!

 

We keep a Wordpress blog using a tweaked Wordpress theme called Hybrid News.  This sets up a front page that has an excerpt and a thumbnail image.  You can see what I'm talking about here:

 

http://www.jokeandbiagio.com

 

Problem is, setting a thumbnail image isn't possible from an iPhone, and it's tough to write fast posts that look good.

 

What I'm trying to set up is a way to LOOP through an image array, based on the category I set for the post.

 

So if a post is in category "SQ" for instance, I'd like to have an array of 3 images. A post to "SQ" would use image 1, next post would use image 2, next post image 3, following post would then start over at image 1.

 

Right now I'm using this code, which only has a default image per category, and adds the thumbnail to the appropriate slot on the theme's front page:

<?php
			if ( in_category( 'SQ' ) )
			$default_image = 'http://www.jokeandbiagio.com/wp-content/uploads/2009/09/twitterview_scream_queens_th.jpg';
			elseif ( in_category( 'field' ) )
			$default_image = 'http://www.jokeandbiagio.com/wp-content/uploads/2009/10/Mission-X-Tommy-Gun-Garage.jpg';
			elseif ( in_category( 'office' ) )
			$default_image = 'http://www.jokeandbiagio.com/wp-content/uploads/2009/09/typewriter-keys-blue_med.jpg';
?>

<?php get_the_image( array( 'custom_key' => array( 'Medium', 'Feature Image' ), 'default_size' => 'medium', 'default_image' => $default_image ) ); ?>

 

How could I build a "well" of images so instead of having one default, there's 3, and each time I post, the thumbnail becomes the next image in the array? I'm figuring it's using some kind of loop.  I admit to being a PHP newbie, and while I found some interesting information here:

 

http://www.efishdesign.com/tutorials/php.php#part4

 

and on this forum here:

 

http://www.webdeveloper.com/forum/archive/index.php/t-112743.html

 

I haven't been able to figure out how to implement the idea of an image array loop into the above code.

 

Thanks so much for any help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.