Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 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_date&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 ) : ?>
  16.     <div class="related_articles">
  17.     <div class="rptitle">Other Posts in this Category</div>
  18.     <ul>
  19.     <?php foreach ( $posts as $post ) : ?>
  20.     <li><a href="<?php the_permalink() ?>" title="<?php echo trim(str_replace("n"," ",preg_replace('#<[^>]*?>#si','',get_the_excerpt()))) ?>"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a> (<?php the_time('F jS, Y') ?>)</li>
  21.     <?php endforeach // $posts as $post ?>
  22.     </ul>
  23.     </div>
  24.     <?php endif // $posts ?>
  25.     <?php
  26.     $post = $this_post;
  27.     unset($this_post);
  28.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement