Support » Plugin: Yet Another Related Posts Plugin (YARPP) » [Plugin: Yet Another Related Posts Plugin] Cache problems and post thumbnails

  • Hello all

    I have YARPP installed and love it, and yesterday I moved it to a prominent location on our live blog. I am utilizing custom templates, which I will discuss momentarily.

    I am experiencing two problems with the plugin.

    Problem #1: For some reason, images are not displayed for new content. The custom template should pull an image and display it, and it does for 90% of the related posts. However, on occasion, it displays an empty image field. This is strange, because it does not display the DEFAULT image (as is set in the custom template), just an empty square.

    I have noticed that this happens primarily with new content. When we create a post, that post displays in lists of related posts, but there’s no image. I think that this must have something to do with YARPPs cache.

    You can see an example here:

    PROBLEM #2: I am a writer, not a coder. But, I know a little bit. So I didn’t write this code by hand. What I’d like to do is pull the post thumbnail, NOT the first image in the post. However, I’m not sure why that’s not happen. Here’s my custom template:

    <?php /*
    Post Thumbnail Template
    <h3 class="widget_sTitle">Related Posts</h3>
    <?php if ($related_query->have_posts()):?>
    	<ul class="related-posts">
    		<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
    				//Set character cap, default is 30
    				$related_thumbnail = get_post_meta($post->ID, "thumbnail_url", $single = true);
    				$imgthumb = catch_that_image();
    				$tit = the_title('','',false);
    				$tit1 = substr($tit, 0, 60);
    				if (strlen($tit) > 60) { $tit2 = "$tit1 ..."; } else { $tit2 = "$tit"; }
                	<?php if ($related_thumbnail != "") : ?>
                		<img src="<?php echo $related_thumbnail; ?>" alt="<?php the_title(); ?>" width="100" />
                    <?php else : ?>
    				<?php if ($imgthumb != "") : ?>
    					<img src="<?php echo $imgthumb; ?>" alt="<?php the_title(); ?>" width="100" />
    				<?php else : ?>
    				    <img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" alt="<?php the_title(); ?>" width="100" />
    				<?php endif; ?>
                    <?php endif; ?>
    				<a href="<?php the_permalink() ?>" rel="bookmark"><b><?php echo $tit2; ?></b><br /><?php echo string_limit_words(get_the_excerpt(), 20); ?>&hellip;</a>
    		<?php endwhile; ?>
    <?php else: ?>
    	<p>No related posts found</p>
    <?php endif; ?>

    Can you help me figure out how to pull the thumbnail?

    Two ancillary questions:
    #3: Is there any way to trim the thumbnail, as opposed to compressing its dimensions in order to fit the alloted space?
    #4: For some reason, sometimes, the_excerpt displays with formatting (bolding, etc) that gets passed down to everything below it. That’s strange, because the excerpt in question never contains any formatting.

    Ideas/suggestions on any or all of the above would be greatly appreciated.

    Thanks! – Jim

Viewing 1 replies (of 1 total)
  • Hi Jim,

    Unfortunately, if YARPP is actually picking out those posts for you, then YARPP is doing its job… it looks like the problem might be what you’re doing with that information in the template. In particular, you’re using this function catch_that_image which is not a standard WordPress function. I think you’ll have to check with whatever theme or plugin implemented that function to see where the problem lies.


Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] Cache problems and post thumbnails’ is closed to new replies.