Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- related posts list with excerpt and class active for single.php
- by alchymyth 10/03/2011
- */
- $this_post_id = $post->ID;
- $categs = get_the_category($post->ID);
- foreach($categs as $cate) { $post_cats[] = $cate->term_id; }
- $args = array(
- 'posts_per_page' => -1,
- 'category__in' => $post_cats
- );
- $this_query = new WP_query( $args );
- if($this_query->have_posts()) :
- while($this_query->have_posts()) :
- $this_query->the_post();
- ?>
- <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>
- <?php the_excerpt();
- endwhile;
- endif;
- wp_reset_query();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement