Add Related Posts Before Comments Link in Thesis

This post has been marked as old. The code might no longer work. Comments have been disabled as this is no longer maintained. Use the search on the right to find a newer tutorial.

On one of my projects, the client needed a listing of Related Posts and the Add This link to show up below the post’s content, but before the Comments link (see the image above).

If you use thesis_hook_after_post, your function appears AFTER the Comments link. So what we need to do is remove the comments link, write a new function that contains Add This, Related Posts, and the Comments link function, and stick that at the end of the post. For the Related Posts, I’m using this plugin.
[php]/* Add This, Related Posts, and Comments */
remove_action(‘thesis_hook_after_post’,’thesis_comments_link’);
function custom_related_posts() {
if(is_single() || is_front_page()): ?>
[your AddThis.com code]
<?php wp_related_posts();
thesis_comments_link();
endif;
}
add_action(‘thesis_hook_after_post’,’custom_related_posts’);[/php]

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

    • Bill Erickson says

      If you don’t want it showing up on the homepage, remove the if(is_front_page()), so it’s just if(is_single())

  1. hooman says

    just one question,
    what if i want have “related postd” only in my single page, not in all of my front page,
    i used ” if(is_single()): ?> ” , but it cause some problem in comments …

  2. hooman says

    ok this worked!

    /* Add This, Related Posts, and Comments */
    function custom_related_posts() {
    if(is_single()): ?>
    <?php wp_related_posts();
    endif;
    }
    add_action('thesis_hook_after_post','custom_related_posts');