Show Related Posts in Genesis without any Plugin

Showing related post below every article is one of the best way to control the bounce rate of your website, as users get more content on related topics. You can you use some great plugins like WordPress Related Posts, Yet Another Related Posts Plugin, Relevant  to solve this purpose. But it’s always better to  use less number of plugins to keep website fast loading. If you are a Genesis framework user you can easily show related posts below every post by adding some php code in child theme’s functions.php file. But before any experiments please backup your blog. If something goes wrong your blog will not load.

You can use the inbuilt editor of WordPress to add the code, but it’s better to download functions.php from child theme folder inside  /wp-content/theme folder of WordPress. There are two options for related posts, you can show them according to categories or tags attached with post, with a bit of coding knowledge you can create related post function with both tags that will be more precise.

Update: Show Related Posts with Thumbnails in Genesis without any Plugin

Related post based on category:

Code for tag based related post display is nearly about same. Just replace all “cat” with “tag” and “categories” with “tags”. To change number of related posts shown change the number in [ showposts => 4,  ] line , to ignore sticky posts to appear in related section just change the number “0” to “1” in [ignore_sticky_posts => 0,] line.

Those using old version of Genesis framework or child themes will face problem with this code as they have recently added HTML5 Markup on all the themes. To solve it just replace genesis_after_entry_content‘ with ‘genesis_after_post_content‘.

Thats all for now will be back with some new Genesis tutorials soon. Have any query ? Just comment below.




Comments

  1. Great, I finding this one. So can you explain more detail? I don’t know where to add this code?

  2. I am so happy you posted this. I need this because my hosting provider does not allow the popular related post plugins. I currently use special post plugin from codecanyon that is awesome. They also cache the query so it’s not hitting the database every time. I believe it does a refresh every 24 hours.

    Could you update the code to do that?

  3. Thanks Arup. My blog looks cool with this Related Post widget. 🙂

  4. Please does the plugin comes with thumbnails?

    • Look as I mentioned in post title, it’s no plugin. To show thumbnail using the code, you have to fetch the featured images on the post and add that to $related.

  5. Thanks brother, You are too good.

  6. Alip iskandar says:

    Thanks, I made related post in my blog.

  7. its a great pleasure to be here.

  8. am so happy you posted this. I need this because my hosting provider does not allow the popular related post plugins. I currently use special post plugin from codecanyon that is awesome. They also cache the query so it’s not hitting the database every time. I believe it does a refresh every 24 hours.

    Could you update the code to do that?

  9. Nice tutorial. Explained easily.
    It would be good if this feature was built in because some people do not like coding at all.
    Thanks Arup.

  10. Arup this is awesome! thank you so much for sharing.
    Can you explaim me again how to add thumbnails?
    thank you so much!

  11. Vineet Gupta says:

    Thanks mate for sharing this. It works well 🙂

  12. That’s what i was looking for. Installing a number of plugins eventually slows down wordpress. This code will do up the task. Thanks Arup Bro for sharing with us.

  13. Hey Thanku for this script.
    How may i add thumbnails to it and give look like jetpack related posts.

    Regards

  14. Hey Arup Ghosh Thnku for script.
    how can i change position of related posts?
    Pls Reply fast

    Regards.

  15. Thanks for the effort to provide this code. But it’s not working on my site. Can you please have a look and resolve it?

  16. Hey thanks for this!

    However, is there anyway to make it more complex? Maybe make it related based on Categories & Tags combined?

    Thanks!

  17. where the preview ?

    its better if you add the preview

Speak Your Mind

*