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.

Add Related Posts Before Comments Link in Thesis

related

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.

/* 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');

Bill Erickson is a WordPress Consultant who builds custom websites using WordPress as a CMS and the Genesis framework. He contributes to the WordPress community through free themes, plugins, tutorials, and core patches. He's also a cofounder of the BIL Conference (the open analog to the TED Conference).

Looking for more great tutorials? See them all!

Comments

  1. Michael says:

    Is there a way to not show on the home page. Causing problems with my skin.

    • 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())

  2. hooman says:

    thats exactly what i was looking for. tnx : )

  3. 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 …

  4. 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');

  5. awesome code man!