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
- update by EntarteteMuzak 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()) : ?>
- <?php $count = 0; ?>
- <?while($this_query->have_posts()) :
- $this_query->the_post(); ?>
- <?php $count++; ?>
- <?php if ($count%3== 0) : ?>
- <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
- <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(); ?>
- </div>
- <div class="clearfix"></div>
- <hr />
- <?php else : ?>
- <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
- <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(); ?>
- </div>
- <?php endif; ?>
- <?endwhile; ?>
- <?endif; ?>
- <?wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement