display first post in category
-
Hi within my archives.php i’ve put the following code to display the first post and list the rest after. For some reason it’s always showing the last post and not the last post of the category. Any idea as to why? I’m clueless.
All I want is for the first post of any category to be displayed and the rest to be displayed as lists.
Any help would be appreciated.
Thanks!
<?php if (have_posts()) : ?>
<!-- First Post -->
<?php $top_query = new WP_Query('showposts=1'); ?><?php while($top_query->have_posts()) : $top_query->the_post(); $first_post = $this_category->ID; ?>
<div class="post top" id="post-<?php the_ID(); ?>">
<h2 class="first"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span class="postmetadata">• <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> <?php edit_post_link('Edit', '(', ')'); ?></span><div class="entry">
<?php the_content("<span class=\"continue\">" . __('Continue reading','') . " '" . the_title('', '', false) . "'</span>"); ?>
</div>
</div><?php endwhile; ?>
<!-- Next few posts -->
<?php while(have_posts()) : the_post(); if(!($first_post == $post->ID)) : ?><div class="post lastfive" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span class="postmetadata">• <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> <?php edit_post_link('Edit', '(', ')'); ?></span><div class="entry">
<?php the_excerpt(); ?>
</div>
</div><?php endif; endwhile; ?>
- The topic ‘display first post in category’ is closed to new replies.