WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Yet Another Related Posts Plugin] Featrue REQ: if no related posts - display nothing (3 posts)

  1. pedjas
    Member
    Posted 4 years ago #

    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.

  2. Golok
    Member
    Posted 4 years ago #

    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; ?>
  3. 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.

Topic Closed

This topic has been closed to new replies.

About this Topic