How to Display Related Posts in Thesis Theme without a Plugin. Its always recommended to display related posts in your blog, it not only improves user experience, but also helps to boost search engine rankings.

After reading complete post, its necessary to include something related to that article. In many WordPress themes, links to next and previously published posts will be displayed, which is also a good option.
If you are using Genesis Theme, here is an article for you: Display related posts
Why to Display Related Posts without Using a Plugin ?
We specifically mention “Without a Plugin” context in the title and there is a special reason behind it. It is not always good to use too many plugins on any blog, they surely will affect the loading speed. So, we always like to use a piece of handy code for small functionality and recommend the same for our readers.
Now, coming to related posts in thesis, they can be displayed based on categories and tags. But using categories is the best method and here are some specific reasons for that.
Learn: How to customize 404 Error Page in Thesis Theme
Why to display Category Based Related Posts ?
- In most of the blogs tags are not used at all, but categories will be assigned.
- Compared to tags, more relevant results will be displayed for any category.
- The code used will be light and can be implemented easily.
These are some simple reasons which can be considered to some extent.
Read: Thesis 1.8.5 Now Available for Download
Display Related Posts in Thesis Theme without a Plugin
Follow these steps to add related posts to single post page.
- Login to WordPress dashboard and go to Appearance Menu.
- Open “
custom_functions.php” file, add below code to it and Update the file . - Now, open any post in your blog to check if code is working on it.
function custom_related_posts() {
if (is_single()) {
global $post;
$current_post = $post->ID;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<div class="related-posts">
<h4>Related Articles...</h4>
<ul>
<?php
$posts = get_posts('numberposts=8&category='. $category->term_id . '&exclude=' . $current_post);
foreach($posts as $post) :
?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?><?php endforeach; ?>
</ul>
</div>
<?php
}
wp_reset_query();
}
add_action('thesis_hook_after_post','custom_related_posts');
Functionality of this Code
- Conditional tag
is_single()is used and hence related posts are displayed in single post page only. - By default, 8 posts are displayed and change the number to any positive number based on the requirement.
- Also, you can modify the heading of related posts by using a custom text.
Styling Related Posts in Thesis Theme using CSS
Now, final part is to style these related posts using CSS. Add the below code to custom.css file and update it.
.custom .related-posts { margin:10px 0; }
.custom .related-posts h4 {font-size: 18px;line-height: 36px;font-weight:bold;}
.custom .related-posts ul {list-style: square outside none;}
.custom .related-posts ul li {padding:5px 10px;}
.custom .related-posts li a { text-decoration:none; }
.custom .related-posts li a:hover { color:#333; }
Finally, you have successfully added “Related Posts to Thesis Theme”. If you have any query regarding this article, drop a comment and we are always glad to help you.


How to Add 4 Column Footer to Thesis Theme
How to Install Thesis Theme on WordPress Blog
How to Remove Comments on this Entry Are Closed in Thesis
Thesis 2.0 Review – Unbiased with Screenshots
How To Add Author Bio Box below single post in Thesis Theme
10 Useful WordPress Plugins for Thesis Theme Customization
I tried to use this in my blog. After putting the code in my custom_functions.php file I reloaded my blog. Sidebar widgets got messed up. Any suggestions?
Using plugin not so good cause it slows down loading page so using code is the best way to for showing related post plugin.