Advertisement
salmancreation

Display Single Post Related Posts by Category in sidebar

Jan 18th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php <span class="catagoryHeading">এই বিভাগের আরও খবর</span>
  2.                        
  3.  
  4. <ul class="catagory">
  5.                        
  6. <?php
  7.  
  8. $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 7, 'post__not_in' => array($post->ID) ) );
  9. if( $related ) foreach( $related as $post ) {
  10. setup_postdata($post); ?>
  11.  
  12.         <li>
  13.         <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
  14.         </li>  
  15. <?php }
  16. wp_reset_postdata(); ?> </ul>
  17.  
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement