• Hi there,

    I’m setting up my new blog and I managed to get rid of most problems. I’m using this related posts plugin, and there is one thing I can’t seem to figure out.

    I would like to show the related posts on my homepage. I know the I should add the <?php wp_related_posts()?> code right behind

    <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'ladylucktheme' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'ladylucktheme' ) . '</span>', 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    But the problem is.. I can’t find that code in my content.php . Where do I add this <?php wp_related_posts()?> code now?

    The link to my blog is http://denisejoanne.com. It’s still under construction, so excuse me for the mess and loads of test posts! :)\

    Thanks in advance!

    https://wordpress.org/plugins/wordpress-23-related-posts-plugin/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Hey,

    thanks for reaching out! I have checked out your blog and correct me if I am wrong, you are using a custom made theme? Would you be so kind and copy/paste the code you have in your content.php?

    Looking forward to your reply,
    Petra

    Thread Starter Nizzylikes

    (@nizzylikes)

    You’re completely right, it’s custom made!

    This is what’s in my content.php:

    <?php
    /**
     *
     * content*.php
     *
     * The post format template. You can change the structure of your posts or add/remove post elements here.
     *
     * 'id' - post id
     * 'class' - post class
     * 'thumbnail' - post icon
     * 'title' - post title
     * 'before' - post header metadata
     * 'content' - post content
     * 'after' - post footer metadata
     *
     * To create a new custom post format template you must create a file "content-YourTemplateName.php"
     * Then copy the contents of the existing content.php into your file and edit it the way you want.
     *
     * Change an existing get_template_part() function as follows:
     * get_template_part('content', 'YourTemplateName');
     *
     */
    
    global $post;
    theme_post_wrapper(
    		array(
    			'id' => theme_get_post_id(),
    			'class' => theme_get_post_class(),
    			'thumbnail' => theme_get_post_thumbnail(),
    			'title' => '<a href="' . get_permalink($post->ID) . '" rel="bookmark" title="' . strip_tags(get_the_title()) . '">' . get_the_title() . '</a>',
    			'heading' => theme_get_option('theme_' . (is_home() ? 'posts' : 'single') . '_article_title_tag'),
    			'before' => theme_get_metadata_icons('date', 'header'),
    			'content' => theme_get_excerpt(),
    			'after' => theme_get_metadata_icons('comments', 'footer')
    
    		)
    
    );
    
    ?>

    Hope you can help me out!

    Thread Starter Nizzylikes

    (@nizzylikes)

    Anyone? 🙁

    Hey,

    sorry to keep you waited – the content.php won’t do :(. Is it possible to make me a temporary account on your blog, so that I can take a closer look. If not, can you copy/paste the content (if you have that file) of index.php? Can you make a screenshot of the theme’s files (it will be quicker this way)?

    Once again, sorry for the late reply, take care and have an amazing day,
    Petra

    Thread Starter Nizzylikes

    (@nizzylikes)

    Hi Petra!

    The content of my index.php is

    <?php get_header(); ?>
    			<?php get_sidebar('top'); ?>
    			<?php
    			if (have_posts()) {
    				/* Display navigation to next/previous pages when applicable */
    				if (theme_get_option('theme_' . (theme_is_home() ? 'home_' : '') . 'top_posts_navigation')) {
    					theme_page_navigation();
    				}
    				/* Start the Loop */
    				while (have_posts()) {
    					the_post();
    					get_template_part('content', get_post_format());
    
    				}
    				/* Display navigation to next/previous pages when applicable */
    				if (theme_get_option('theme_bottom_posts_navigation')) {
    					theme_page_navigation();
    				}
    			} else {
    				theme_404_content();
    			}
    			?>
    
    			<?php get_sidebar('bottom'); ?>
    <?php get_footer(); ?>

    Also, these are the theme’s files:
    http://tinypic.com/view.php?pic=359abo5&s=8#.VOYbunbQDVo

    Thank you!

    Hey,

    so we are getting somewhere 🙂
    I think if you add “wp_related_posts();” right after “get_template_part(‘content’, get_post_format());” it should work – but please backup everything before you do the changes.
    Everything put together (the /* Start the Loop */ part) should look like this:

    /* Start the Loop */
    				while (have_posts()) {
    					the_post();
    					get_template_part('content', get_post_format());
    wp_related_posts();
    
    				}

    Save the changes and let me know how it goes,
    Petra

    Thread Starter Nizzylikes

    (@nizzylikes)

    Hi Petra!

    Thanks for your response. I did exactly what you said, but unfortunately it doesn’t seem to work! Nothing changed on the blog!

    Denise

    Hmmm…I was almost 100% sure it will work.
    But I think we have one more option – I have re-checked that screenshot of your other files and would you be so kind and copy/paste the content of the home.php file?

    Take care and have a lovely day,
    Petra

    Thread Starter Nizzylikes

    (@nizzylikes)

    <?php get_header(); ?>
    <?php get_sidebar(‘top’); ?>
    <?php
    if (have_posts()) {
    /* Display navigation to next/previous pages when applicable */
    if (theme_get_option(‘theme_’ . (theme_is_home() ? ‘home_’ : ”) . ‘top_posts_navigation’)) {
    theme_page_navigation();
    }
    ?>
    <?php
    for ($i = 0; $i < $wp_query->post_count; $i++) {
    theme_get_next_post();
    }
    ?>
    <?php
    /* Display navigation to next/previous pages when applicable */
    if (theme_get_option(‘theme_bottom_posts_navigation’)) {
    theme_page_navigation();
    }
    } else {
    theme_404_content();
    }
    ?>
    <?php get_sidebar(‘bottom’); ?>
    <?php get_footer(); ?>

    Here’s the content of my home.php 🙂

    Thank you!

    Thread Starter Nizzylikes

    (@nizzylikes)

    I found that if I put the

    wp_related_posts();

    right after

    theme_page_navigation();

    in the home.php, the related posts do show on the main page. The only problem is that they show below the post, instead of at the end of the post. I’m not sure how to explain, haha!
    Like, they show below the box in which the post is displayed!

    Can you make a screenshot? Maybe this is something that could be regulated via the CSS.

    Take care and have a lovely day!

    Thread Starter Nizzylikes

    (@nizzylikes)

    Oopsies, in my last post I said I put the code right after theme_page_navigation(); but I meant theme_get_next_post();

    Anyway, here’s some screenshots:

    The placement of the Related Posts code in my home.php:
    http://i59.tinypic.com/1zqdg5z.jpg

    And a screenshot of how it looks on my blog:
    http://i59.tinypic.com/1o7rj8.png

    Notice how the related posts show up right under the post? It should appear above the grey horizontal line!

    I left the code where it is in the screenshot above. So if you want to see it in action, you can take a look at my blog!

    I hope we can resolve it soon, because I don’t like how the related posts appear under the grey line and they’re not aligned with the pictures and text in the posts!

    Thank you!!

    Hey,

    looking at it right now – hmmm, I assume you have already tried to put that code right before the theme_get_next_post(); and not after? The alignment can be done via the CSS but we first we need to move those posts. Is this something you wish to achieve? Do you need that horizontal line?

    Take care,
    Petra

    Thread Starter Nizzylikes

    (@nizzylikes)

    Hi Petra,

    Thanks for the fast response! Yes, I have tried that, and it puts the related posts on top of the post, before the title.

    Yes, that’s basically what I’d like to achieve! I do like that horizontal line because it seperates the posts from each other, but if it has to go away for the sake of the related posts, I’d be fine with that.

    Thanks!
    Denise

    Hmmm…it seems that CSS alignment will be a bit more complicated than I originally thought. But let’s try it nonetheless-> go to plugin settings and in the Advanced settings enable custom CSS. There add the following:

    div.wp_rp_content {
          margin-left: 35px;
    }

    Don’t forget to save the changes. Then go to “Appearance”-> “Editor”-> your theme and find the style.css file. There find and change the “border-bottom”:

    .art-post
    {
    background: none repeat scroll 0 0 #ffffff;
    border-bottom: 1px solid #dedede; //change 1px to 0px or just delete this line
    margin: 10px 5px;
    padding: 15px;
    }

    Save the changes and let me know how it goes.

    PS: Sorry for the delayed response, it’s just super busy on our side!

Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘Related posts home page’ is closed to new replies.