Many plugins are available to display Related Posts in Genesis theme, but it is not good to depend on plugins all the time. Hence, follow this simple tutorial to display related posts in Genesis theme without a plugin.

You need to edit these files in your Genesis Child theme folder
functions.php
style.cssAs you are going to edit some files, is advised to backup your child theme.
Also Read : How to Remove or Change Post Meta in Genesis Theme Framework
Related posts can be displayed based on tags or categories. Nick used both tags and categories in his code to display related posts, but we tried to split them and here is the result of it.
Display Related Posts in Genesis based on Category
If you want to display related posts based on the category, then add this code to functions.php file in Genesis Child Theme and save it.
/** Display related posts in Genesis based on Category */ function related_posts_categories() { if ( is_single ( ) ) { global $post; $count = 0; $postIDs = array( $post->ID ); $related = ''; $cats = wp_get_post_categories( $post->ID ); $catIDs = array( );{ foreach ( $cats as $cat ) { $catIDs[] = $cat; } $args = array( 'category__in' => $catIDs, 'post__not_in' => $postIDs, 'showposts' => 5, 'ignore_sticky_posts' => 1, 'orderby' => 'rand', 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-link', 'post-format-status', 'post-format-aside', 'post-format-quote' ), 'operator' => 'NOT IN' ) ) ); $cat_query = new WP_Query( $args ); if ( $cat_query->have_posts() ) { while ( $cat_query->have_posts() ) { $cat_query->the_post(); $related .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . get_the_title() . '</a></li>'; } } } if ( $related ) { printf( '<div><h3>Related Posts</h3><ul>%s</ul></div>', $related ); } wp_reset_query(); } } add_action( 'genesis_after_post_content', 'related_posts_categories' );
Functionality of this code :
- Displays related posts randomly based on category in single post page.
- Define the number of posts to display by changing value in
'showposts' => 5
Also Check : 5 Reasons why we choose Genesis over Thesis
Display Related Posts in Genesis based on Tags
If you want to display related posts based on the tag, then add this code to functions.php file in Genesis Child Theme and save it.
/** Display related posts in Genesis based on Tags */
function related_posts_tags () {
if ( is_single ( ) ) {
global $post;
$count = 0;
$postIDs = array( $post->ID );
$related = '';
$tags = wp_get_post_tags( $post->ID );
foreach ( $tags as $tag ) {
$tagID[] = $tag->term_id;
}
$args = array(
'tag__in' => $tagID,
'post__not_in' => $postIDs,
'showposts' => 5,
'ignore_sticky_posts' => 1,
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-link',
'post-format-status',
'post-format-aside',
'post-format-quote'
),
'operator' => 'NOT IN'
)
)
);
$tag_query = new WP_Query( $args );
if ( $tag_query->have_posts() ) {
while ( $tag_query->have_posts() ) {
$tag_query->the_post();
$related .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . get_the_title() . '</a></li>';
$postIDs[] = $post->ID;
$count++;
}
}
if ( $related ) {
printf( '<div><h3>Related Posts</h3><ul>%s</ul></div>', $related );
}
wp_reset_query();
}
}
add_action( 'genesis_after_post_content', 'related_posts_tags' );
Functionality of this code :
- Displays related posts randomly based on tag in single post page.
- Define the number of posts to display by changing value in
'showposts' => 5
Check This : How to add 3 column footer to WordPress theme
Styling the related posts in Genesis Theme
You need to add this code to style.css file.
.related-posts {
margin: 10px 0;
}
.related-posts h3 {
font-size: 18px;
}
.related-posts ul {
list-style:none;
}
.related-posts ul li {
padding: 3px 0;
border-bottom: 1px dashed #ccc;
}
.related-posts ul li a{
font-size:14px;
text-decoration:none;
}
Now, you are done with everything and its time check the related posts in your blog. If you got any query regarding this article, please drop a comment and we will get back to you soon.


How to Display Recent Tweets in WordPress Blog
How to Add nofollow to WordPress Menu Links
How to Auto Post to Google Plus from WordPress Blog
How to Install WordPress Using SimpleScripts
How to Customize Genesis Post Excerpts
Is it possible to show thumbnails in related posts?
Yeah, its possible and we will write an article on that, very soon
Will this work for Thesis users too ??
This code works for Thesis Theme also, but you need to replace Genesis hooks with Thesis hooks, hope you understand it.
Could you please tell me how to get related post as thumbnails, and how to get social icons (like yours, to the top right corner “stay connected widget”)
Thanks n advance
Yeah sure, will write an article on “Related Posts with Thumbnails” and “Social Icons Widget” for you !
Hi,
One thing out of context, Not sure you will tell me or not.
How to have a Logo behind code like yours.If you are not interested in sharing your secret at least give me some reference for that.
Thanks,
Thanks for this!
Do I just have to Copy Paste the code into the stylesheet or any other modifications are to be made before that? Because I cannot find any different with and without the stylesheet code.
I am not sure about where to enter the code exactly in the stylesheet. Can you brief me on this?
Nice. Thank you! Yes, it would be really nice with thumbnails!
How to display it in between ? i mean say after 200 words ?
Hello there!
Thanks for the great tutorial. Do you have a sample of what the output actually looks like?
Thanks again…
I already answered my last question for myself. I just went and did it!
I tried the code that you shared above (for the related posts by category) in my Genesis child theme’s functions.php and it works perfectly. However, I had to add the CSS class “related-posts” to the “div” that you that you created, otherwise the CSS wouldn’t pick up on it.
Finally, could you tell me how to convert the “related posts by category” code to a plug-in? I had trouble with some of the other plugins out there. I heard there was some kind of speed/memory benefit by putting this code in a plugin vs. putting it in the functions.php.
Your thoughts either way?
Thanks.
Thanks a lot for this tutorial.. I really needed it.
But when are you getting to make one with thumbnails??
Perfect. Just what I needed!