Alqoe

RelatedCat

Feb 11th, 2013
256
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. $this_post = $post;
  3. $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
  4. $posts = get_posts('numberposts=6&offset=0&orderby=post_dat e&order=DESC&category='.$category);
  5. $count = 0;
  6. foreach ( $posts as $post ) {
  7. if ( $post->ID == $this_post->ID || $count == 5) {
  8. unset($posts[$count]);
  9. }else{
  10. $count ++;
  11. }
  12. }
  13. ?>
  14.  
  15. <?php if ( $posts ) : ?><h3>Artikel Terkait :</h3><ul><?php foreach ( $posts as $post ) : ?>
  16. <li>
  17. <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li><?php endforeach // $posts as $post ?></ul>
  18. <?php endif // $posts ?>
  19. <?php $post = $this_post;
  20. unset($this_post);
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment