Ok, nevermind my previous question. I’ve got the coded added in and it’s working great except the posts are pulling the same image. So I’ve got 2 different posts with different images, but they both are pulling the first image out of the newer post. Any ideas?
Here’s my code:
<div class="post">
<?php
if(in_category(4)) {
$args = array(
'post_type' => 'attachment',
'numberposts' => 1,
'order' => 'ASC',
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$thePic = wp_get_attachment_image($attachment->ID);
}
}
$args = array(
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
$picCount = count($attachments);
}
?>
<!-- $$$$$$$$$$$$$$$$$$ This is the gallery post bit $$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<div style="clear: both;"></div>
<div class="post">
<div style="float: right; width: 185px; clear: right; margin-top: 0px; margin-bottom: 0px; padding-top: 0px; margin-left: 0px;">
<h2>Album:<br /><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_time('F jS, Y') ?></a></h2>
<br />
<div>This album contains <?php echo $picCount; ?> photos.</div>
</div>
<div style="float: left;"><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></div>
<?php the_excerpt('Read the rest of this entry »'); ?>
<div class="post"><p class="divide">
<?php if ('open' == $post-> comment_status) : // kommentare erlaubt, dann ?>
<?php else : // wenn kommentare deaktiviert, dann ?>
<?php endif; ?>
Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</p></div>
</div>
<?php } else { ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2><?php the_time('F jS, Y') ?>
<?php the_content(__("Read the rest of this entry »")); ?>
<p class="divide">
<?php if ('open' == $post-> comment_status) : // kommentare erlaubt, dann ?>
<?php else : // wenn kommentare deaktiviert, dann ?>
<?php endif; ?>
Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</p>
<?php } ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<div class="post">
<img src="<?php bloginfo('template_directory'); ?>/images/404error.gif">
<h2 align="center">Sorry, but this page does not exist.</h2>
</div>
<?php endif; ?>
<div class="post" align="center">
<?php posts_nav_link(' | ','« Latest Entries','Previous Entries »'); ?>
</div>