Listing all posts from current category on page

Good news! I think you’re making things harder for yourself than they need to be. If I understand your question, you’re looking for rewind_posts(). The always useful Digging Into WordPress has a nice summary of it.

Because both tasks involve looping through the same query, you don’t need get_posts() at all.

Instead, you’ll want to use the aforementioned rewind_posts() something like this:

<?php if( have_posts() ) : ?>
<!-- Your list of posts -->
<ul>
<?php while ( have_posts() ) : the_post(); ?>
<li><a href="https://wordpress.stackexchange.com/questions/51342/<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>

<?php rewind_posts(); // second <del>verse</del> query, same as the first ?>

<?php while( have_posts() ) : the_post(); ?>

<!-- your "blog-style" stuff -->

<?php endwhile; endif; ?>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)