Support » Plugin: Yet Another Related Posts Plugin (YARPP) » Default thumbnail if no related image available

  • 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/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Default thumbnail if no related image available’ is closed to new replies.