Hi, I'm having a bit of problem with putting multiple loops on the single.php page.
Basically, I want two additional loops showing specific posts from specific categories as well as the full text of a post. For some reason the loops are conflicting with one another – instead of showing the post text, it shows the content of one of the other loops.
The code I'm using for the additional loops is:
<?php $posts = get_posts( "category=10&numberposts=1" ); ?> <?php if( $posts ) : ?><?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <?php the_content('Read more »'); ?> <?php endforeach; ?> <?php endif; ?>
(the only difference between the two additional loops is the category number and number of posts)
The code to display the full single post is :
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <h2><?php the_title(); ?></h2> <div class="contenttext"> <?php the_content('<p>Read more »</p>'); ?> </div> <?php link_pages('<p><strong>Pages:<strong> ', '</p>', 'number'); ?> <p class="postinfo"><strong>Posted:</strong> <?php the_time('F jS, Y') ?> under <?php the_category(', ') ?>.<br /> <a href="<?php comments_link(); ?>"><strong>Comments:</strong> <?php comments_number('none','1','%'); ?></a> <?php edit_post_link('Edit this post',' | ',''); ?></p> <?php comments_template(); ?> <?php endwhile; else: ?> <p>No matching entries found.</p> <?php endif; ?> </div>
You can see them in action here.
I fear my knowledge of PHP and/or WordPress isn't enough to figure this one out by myself, so if anyone has any ideas I'd be most grateful. Thanks!