How to display related Post in Wordpress without Plugin

How to display related Post in Wordpress without Plugin

In This Article, I would like to show you how easy it is to display related Post in Wordpress without Plugin. Most People Want to show related posts by using custom WP_Query for easily editing and style according to there demand. Here You will see how easy it is to display Your related Post.

Just copy this code and add in your theme single.php file.

// Get Current Post Id for excluding from related Post Query
$post_id = get_the_ID();
$args =
array( 'post_type' => 'post',
'post__not_in' => array($post_id),
'posts_per_page' => 3,
'post_status' => 'publish',
'orderby' => 'DESC' );
$sensod_query = new WP_Query( $args );
if ( $sensod_query->have_posts() ) : while ( $sensod_query->have_posts() ) : $sensod_query->the_post();
the_title();
endwhile; endif; wp_reset_postdata();

I am sure you guys like it. Feel Free to leave your comment if you guys need any further assistance.