Sticky posts on Archive pages – problems with 2 loops
-
Hi There,
I’m trying to use 2 loops to pull in sticky posts first and the rest of the posts 2nd on archive pages.
I’m finding that my styling is being applied but not the ordering. As it’s still ordering the posts chronologically (or Alphabetical if I turn my alphabet listings plugin on).
With the code I’ve created I thought that all the stickys should get printed first and then the rest of the posts.
Anyone know where I’m going wrong?
Appreciate any help.
Thanks,
Greg
<?php if (have_posts()) : ?>
<div class="results">
<h2 class="pagetitle-result"><?php single_cat_title(); ?> courses</h2><?php #STICKY POSTS LOOP ?>
<?php while (have_posts()) : the_post(); ?>
<?php if(is_sticky()) { ?><div class="entry featured">
<div id="post-<?php the_ID();?>">
<p class="feathead">Featured course</p>
<h2>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h2></div>
</div>
<?php } ?><?php endwhile; ?>
<?php while (have_posts()) : the_post(); ?>
<?php if(!is_sticky()) { ?><div class="entry">
<div id="post-<?php the_ID();?>"><h2>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h2>
<div class="permaresult">" title="Permanent Link to <?php the_title(); ?>">View details</div>
</div>
</div>
<?php } ?>
<?php endwhile; ?>
<div class="clear"> </div>
<div class="navigation">
<?php if(function_exists('wp_pagenavi')) : wp_pagenavi(); else: ?>
<div class="alignleft"><?php next_posts_link('Next page »') ?></div>
<div class="alignright"><?php previous_posts_link('« Previous page') ?></div>
<?php endif; ?>
</div>
</div>
<?php else : ?>
<div class="entry">
<h2 class="center">Not Found</h2>
< </div>
</div>
<?php endif; ?>
- The topic ‘Sticky posts on Archive pages – problems with 2 loops’ is closed to new replies.