WordPress.org

Support

Support » Plugins and Hacks » Related Posts » [Resolved] Related Posts Not Showing in Posts

[Resolved] Related Posts Not Showing in Posts

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey Jim,
    I think there’s nothing nothing to worry about… yet 🙂

    Our plugin has two types of related posts:
    (1) posts you see below the editor (within your WP dashboard) are related posts from other bloggers in our network and you have to click on them to insert them in a post and
    (2) related posts from your own blog that are automatically added to your posts, but are displayed only when you click on single post

    Now… I can see related posts from (2) when I click on individual post, so plugin is working. If you would like to see your related posts shown on index page too, you’ll have to add a line of code in our index template file.
    If you like, you can also insert some related articles from other bloggers writing about similar topic…

    Hope this helps. If you have any other question or something, I’ll gladly help 🙂

    Take care & have a nice day,
    Mateja

    Mateja,

    The type of related posts that I was referring is number 2 from your response, which are related posts from my own blog.

    They do appear if I click on individual posts as you said, however, I’d prefer that they also show embedded within the individual posts on the index page, that is without having to click the post.

    You mentioned adding a line code to your index template file. Can you tell me the code to add?

    Thanks very much for your help,
    Jim

    Let’s do some template hacking then 🙂

    You’ll have to edit index.php file in your current template folder and add some custom CSS rules in Related Posts plugin’s settings.

    First, find the following line of code in the index.php:
    get_template_part( 'content', get_post_format() );

    and add this line just below it:
    wp_related_posts();

    You should end up with something like this:

    <?php
    	if ( have_posts() ) :
    		// Start the Loop.
    		while ( have_posts() ) : the_post();
    
    			/*
    			 * Include the post format-specific template for the content. If you want to
    			 * use this in a child theme, then include a file called called content-___.php
    			 * (where ___ is the post format) and that will be used instead.
    			 */
    			get_template_part( 'content', get_post_format() );
    			wp_related_posts();
    
    		endwhile;
    		// Previous/next post navigation.
    		twentyfourteen_paging_nav();
    
    	else :
    		// If no content, include the "No posts found" template.
    		get_template_part( 'content', 'none' );
    
    	endif;
    ?>

    Second, go to Related Posts plugin’s settings page, expand Customize in the Desktop/Tablet theme settings and copy/paste following CSS rules in the textarea with (pre-set) custom CSS… Later you’ll probably have to tweak CSS rules some more (depending on your theme), but first things first…

    This custom CSS will center related posts sections and left-align sections’ titles:

    .wp_rp_wrap {
    text-align:center;
    }
    .related_post_title {
    text-align:left;
    }
    ul.related_post {
    }
    ul.related_post li {
    }
    ul.related_post li a {
    }
    ul.related_post li img {
    }

    Let me know if you need any further assistance and/or final CSS tweaking.

    Best,
    Mateja

    esmi

    @esmi

    Forum Moderator

    Let’s do some template hacking then

    Let’s not but use a child theme instead…

    @esmi, yes, thank you for bringing this up 🙂

    Jim,
    please read How to Create a Child Theme first and create a child theme for your current theme.
    This way you’ll be able to automatically update your theme without losing related posts every time you do this.

    After creating your child theme, just copy index.php to your child theme and follow the steps described in my previous response.

    If you need help with any of these – just let me know.

    Hey Jim,

    did you manage to get related posts up and running, so I can close this topic?
    Let me know if you need help.

    Best,
    Mateja

    Plugin Author PetraP

    @petrap

    Hey,

    hope you don’t mind, we’ll mark this topic as resolved as there was no response from original author for more than a month.

    If you find yourself with any other questions or if there’s anything that’s not completely clear, do let us know!

    Best,
    Petra

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Related Posts Not Showing in Posts’ is closed to new replies.
Skip to toolbar