WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. floydman
    Member
    Posted 1 year 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()):?>
    <ul>
        <?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
            <?php if (function_exists('has_post_thumbnail')): if (has_post_thumbnail()):?>
    	<li>
    	    <div class="related-thumbnail">
    	        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
    	    </div>
    	    <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>
    	    </div>
    	</li>
    	<?php endif; endif; ?>
        <?php endwhile; ?>
    </ul>
    
    <?php else: ?>
        <p>No related photos.</p>
    <?php endif; ?>
    </div>

    Thank you for your help.

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year 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.

    http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.3.6b5.zip

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic