Yet Another Related Posts Plugin (YARPP)
Default thumbnail if no related image available (2 posts)

  1. floydman
    Posted 3 years ago #

    Hi there,
    I just try to figure out how I can solve my problem. Not every post has a post image, that can be shown along the related post. How can I use a default thumbnail (e.g. a logo of my blog), if no related image is available? I am not a coder, so please be patient with me. I guess, that there is just a missing "else" somewhere. What I try to achieve in simple words is:

    If there is a related "post_thumbnail" than use it, else use default image located at "wp-content/themes/mytheme/images/default_yarpp.jpg"

    At the moment I am using this code in the "yarpp_template_thumbs.php" file:

    <div class="related-posts">
    <h3>Das wäre auch was für dich...</h3>
    <?php if ($related_query->have_posts()):?>
        <?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
            <?php if (function_exists('has_post_thumbnail')): if (has_post_thumbnail()):?>
    	    <div class="related-thumbnail">
    	        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
    	    <div style="clear:both;"></div>
    	    <div class="related-permalink">
    	        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    	<?php endif; endif; ?>
        <?php endwhile; ?>
    <?php else: ?>
        <p>No related photos.</p>
    <?php endif; ?>

    Thank you for your help.


  2. mitcho (Michael Yoshitaka Erlewine)
    Plugin Author

    Posted 3 years ago #

    In case you're interested, YARPP will be adding thumbnail layout support soon, which lets you specify the "default" image. The first version of this is included in the following beta. I'd love to get your feedback on it.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yet Another Related Posts Plugin (YARPP)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic