Support » Plugins and Hacks » [Plugin: Yet Another Related Posts Plugin] Featrue REQ: if no related posts – display nothing

  • When there are no related posts, plugin shows that information. i prefer, to dusplay related posts if there are some, but to show nothing if there are not related posts – like plugin does not exists.

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you use templates, it is pretty easy. The idea is to move the “Related Posts” title inside the first <if> statement and remove the subsequent <else>:

    The following is based on the original “yarpp-template-example.php” file. Just copy the code below into a new file, save it with a different name (such as “yarpp-template-ifonly.php”) and upload it into your active theme folder.

    <?php /*
    Ifonly template
    Author: mitcho (Michael Yoshitaka Erlewine)
    */
    ?>
    <?php if ($related_query->have_posts()):?>
    <h3>Related Posts</h3>
    <ol>
    	<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
    	<?php endwhile; ?>
    </ol>
    <?php endif; ?>

    Thanks Golok. You should also be able to do it in the YARPP options with the builtin template by making the no results text blank.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] Featrue REQ: if no related posts – display nothing’ is closed to new replies.