Advertisement
alchymyth

the wheel reinvented

Mar 10th, 2011
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2. /*
  3. related posts list with excerpt and class active for single.php
  4. by alchymyth 10/03/2011
  5. */
  6. $this_post_id = $post->ID;
  7. $categs = get_the_category($post->ID);
  8. foreach($categs as $cate) { $post_cats[] = $cate->term_id; }
  9. $args = array(
  10. 'posts_per_page' => -1,
  11. 'category__in' => $post_cats
  12. );
  13. $this_query = new WP_query( $args );
  14. if($this_query->have_posts()) :
  15. while($this_query->have_posts()) :
  16. $this_query->the_post();
  17. ?>
  18. <h3<?php if($post->ID == $this_post_id) echo ' class="active"'; ?>><a href="<?php the_permalink(); ?>" title="link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
  19. <?php the_excerpt();
  20. endwhile;
  21. endif;
  22. wp_reset_query();
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement