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.
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tagIds = array();
foreach($tags as $tag) { $tagIds[] = $tag->term_id; }
$args=array(
'tag__in' => $tagIds,
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1
);
$query = new wp_query($args);
if( $query->have_posts() ) {
echo 'Related Posts';
echo '<br />';
while ($query->have_posts()) {
$query->the_post();
?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php
echo '<br />';
}
}
}
?> Hence, using related tag you can get the related posts.
Read Also: Make a simple plugin – WordPress
The ads shown on videos, articles, or websites are called Display ads. You can supply…
Home security is not just about stopping burglars. It is about protecting your family, your…
Customer Loyalty is one of the most important things for brands today. Everyday companies come…
If you’re an international student in Australia and thinking about a course transfer or transferring…
The internet is a critical part of how we do things today. Anything and everything…
Yes, your kids need basketball shoes. Many parents think that shoes will not impact performance.…