mikejandreau :... And what will happens if your wordpress uploads are organized by dates ??... The uploaded images aren't always in wp-content/, but by default in wp-content/year/month...
---------------------------------
To display the thumbnail, or any size of the first attachment relative to a post, I don't use a custom field
I use a function like this one. It looks for the first image relative to a post, uploaded via the write post panel:
function my_post_thumbnail() {
global $wpdb;
global $post;
$post_thumbnail = $wpdb->get_var("SELECT ID FROM $wpdb->posts where post_parent= $post->ID and post_type = 'attachment'");
if ($post_thumbnail == 0) {
echo "";
}
else {
echo wp_get_attachment_image($post_thumbnail, $size='thumbnail', $icon = false);
}
}
This function will output the thumbnail in a html "img src=..." tag if there is an image attached to a the post, but nothing if there is no image...
Then, just use it as a simple template tag, in your loop wherever you want the thumbnail :
<?php my_post_thumbnail(); ?>
To display thumbnails from posts in a specific category, just use query_posts :
http://codex.wordpress.org/Template_Tags/query_posts
Something like :
<?php query_posts('cat=XX'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php my_post_thumbnail(); ?>
<?php endwhile; ?>
Just adjust cat=XX with the ID of the category you want to display.
S.