Today, in this method to displaying related posts based on category, surely to help visitors staying longer on your blog.
Before start changes in any file, I will firstly recommend you to back up your file before start doing anything to your Single.php file, or else you’ll be sorry if anything goes wrong, ok let’s get started.
Login to your WordPress dashboard , go to your Appearance-> Editor and open your Single.php file, and add this code beneath your post content:
Paste below code:
[php]
$posts = get_posts(‘numberposts=6&offset=0&orderby=post_date&order=DESC&category=’.$category);
$count = 0;
foreach ($posts as $post) {
if ( $post->ID == $this_post->ID || $count == 5) {
unset($posts[$count]);
} else {
$count ++;
}
}
[/php]

