WordPress.org

Ready to get started?Download WordPress

Forums

Related Posts by Taxonomy
[resolved] Position related posts after comments link (8 posts)

  1. hpws_rich
    Member
    Posted 11 months ago #

    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/

  2. keesiemeijer
    moderator
    Plugin Author

    Posted 11 months ago #

    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?

  3. hpws_rich
    Member
    Posted 11 months ago #

    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!

  4. keesiemeijer
    moderator
    Plugin Author

    Posted 11 months ago #

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

  5. hpws_rich
    Member
    Posted 11 months ago #

    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!

  6. keesiemeijer
    moderator
    Plugin Author

    Posted 11 months ago #

    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>
  7. hpws_rich
    Member
    Posted 11 months ago #

    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

  8. keesiemeijer
    moderator
    Plugin Author

    Posted 11 months ago #

    You're welcome. I'm glad it worked :-)
    And thank you for the good review. Made my day!

Reply

You must log in to post.

About this Plugin

About this Topic