Hi all,
I am working on a custom template for my studio's blog. The designer wants a custom image to show up as a header for each post (you can see what I mean here BTP
I am using a custom field to make this happen, the probelm being that when I want to show multiple posts on the index.php the most recent image gets duplicated and shows up as the header image for each post. This makes sense because their isn't a custom id attached to each image/post but am wondering if there is a way to achieve my desitred outcome (that being, the correct image for each post) without having to create a new field for each one. The code I am using is below:
In the header.php:
<?php
$image = get_post_meta($post->ID, 'bg', true);
?>
and in the index.php:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="post_header"><a href="<?php the_permalink() ?>"></a></div>
<p class="small">Posted by <?php the_author(); ?> on <?php the_time('j F, Y') ?></p>
<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('Read the rest of this entry »'); ?>
<p class="postmetadata"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
<?php
$comment_array = array_reverse(get_approved_comments($wp_query->post->ID));
$count = 1;
?>
<?php if ($comment_array) { ?>
<?php foreach($comment_array as $comment){ ?>
<?php if ($count++ <= 1) { ?>
<p class="comment_excerpt"><?php comment_excerpt(); ?></p>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
</div> <!-- end of content -->
Where the div class post_header shows the image.
Any help would be appreciated.