WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Position related posts after comments link

[Resolved] Position related posts after comments link

  • hpws_rich
    Member

    @hpws_rich

    I love this plugin — simple and easy to use. One thing I was wondering if it was possible was whether the function can be adjusted so that the related posts are positioned after the comments link below the post. So instead of the order being:

    – Post content
    – Related posts
    – Comments link

    it would be:

    – Post content
    – comments link
    – related posts

    Thanks!
    Rich

    http://wordpress.org/plugins/related-posts-by-taxonomy/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author keesiemeijer
    Moderator

    @keesiemeijer

    Hi hpws_rich I’m glad you like the plugin. What are you using now to display the related posts? The shortcode, the widget or the function?
    What theme are you using?

    hpws_rich
    Member

    @hpws_rich

    Hi! Sorry didn’t think to include that info before — I’m using the function because I wanted it show up for each post automatically. I’m using the twentytwelve theme.

    Thank you!

    Plugin Author keesiemeijer
    Moderator

    @keesiemeijer

    Can you post the full template file with the function in it here. See the Forum Rules for posting code.

    hpws_rich
    Member

    @hpws_rich

    The function is listed in the theme functions template only. You can view it here:

    http://pastebin.com/x61HGWK7

    The function is at the very bottom of the template.

    Thanks!

    Plugin Author keesiemeijer
    Moderator

    @keesiemeijer

    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost.

    Replace the function and filter with this:

    function add_related_posts_after_post_content() {
    
        //check if it's a single post page.
        if ( is_single() ) {
    
            // add more shortcode parameters to this string if you want
            $shortcode = '[related_posts_by_tax posts_per_page="3" format="links" title="You May Also Like:"]';
    
            echo do_shortcode( $shortcode );
        }
    }

    and replace this in content.php

    <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>

    with this:

    <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    <div class="author-info">
    <?php add_related_posts_after_post_content(); ?>
    </div>

    hpws_rich
    Member

    @hpws_rich

    Fantastic! That worked like a charm…thank you so, so much.

    And I’ll definitely be making a child theme with all these code changes so things don’t get messed up when updates are released.

    Thanks!
    Rich

    Plugin Author keesiemeijer
    Moderator

    @keesiemeijer

    You’re welcome. I’m glad it worked 🙂
    And thank you for the good review. Made my day!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Position related posts after comments link’ is closed to new replies.