Advertisement
Guest User

Show Sticky Posts at the Top Of Category Archive

a guest
Apr 6th, 2011
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php  
  2. // get the current category
  3. $category = get_the_category();
  4. // get the sticky posts in the category
  5. query_posts(array( 'post__in' => get_option('sticky_posts'), 'orderby' => 'title', 'post_date' => 'DESC' , 'cat' => ''.$category[0]->cat_ID.'' ));
  6. ?>
  7. <?php if (have_posts()) : ?>
  8. <?php
  9. if ($cat)
  10. {echo "<h2>Articles in " . get_the_category_by_ID($cat) . "</h2>";}
  11. ?>
  12.     <ul id="archive-list">      
  13.     <?php while (have_posts()) : the_post(); ?>            
  14.         <li class="sticky"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span>Updated on <?php the_modified_date(); ?> at <?php the_modified_time() ?></span></li>
  15.     <?php endwhile; ?>
  16.     </ul>  
  17.  
  18. <?php endif; ?>
  19.  
  20.  
  21. <?php  
  22. // get the non-sticky posts in the category
  23. query_posts(array( 'post__not_in' => get_option('sticky_posts'), 'orderby' => 'title', 'post_date' => 'DESC' , 'cat' => ''.$category[0]->cat_ID.'' ) );
  24. ?>
  25. <?php if (have_posts()) : ?>
  26.     <ul id="archive-list">      
  27.     <?php while (have_posts()) : the_post(); ?>            
  28.         <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span>Updated on <?php the_modified_date(); ?> at <?php the_modified_time() ?></span></li>
  29.     <?php endwhile; ?>
  30.     </ul>  
  31.  
  32. <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>
  33.  
  34.     <?php else : ?>
  35.  
  36.         <h1 class="center">Sorry, no articles have been published in the <?php if ($cat) {echo "" . get_the_category_by_ID($cat) . "";} ?> category.</h1>
  37.         <?php include (TEMPLATEPATH . '/searchform.php'); ?>
  38.  
  39. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement