Show related posts in WordPress without any plugin

WordPress For Mini-Sites And Sales Letters

You can show related posts in WordPress without any plugin and this will reduce your loading fast.

Using a simple code you can get related posts in WordPress. Simply write the below code and put this code anywhere you want to show on your website.

Example of related posts:

$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tagIds = array();
foreach($tags as $tag) { $tagIds[] = $tag->term_id; }

'tag__in' => $tagIds,
'post__not_in' => array($post->ID),

$query = new wp_query($args);
if( $query->have_posts() ) {
echo 'Related Posts';
echo '<br />';
while ($query->have_posts()) {
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
echo '<br />';

Hence, using related tag you can get the related posts.

Read Also: Make a simple plugin – WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *