Forums

Yet Another Related Posts Plugin
Hide widget when no related content (6 posts)

  1. smartinec
    Member
    Posted 1 year ago #

    How can I completely hide (including title) the Related Posts widget when there is no related content to display?

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

  2. Triple P
    Member
    Posted 12 months ago #

    Use a yarpp template, e.g.:

    <?php if ($related_query->have_posts()):?>
    <h3>Related Posts</h3>
    <ul>
    	<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    	<?php endwhile; ?>
    </ul>
    <?php else: ?>
    <?php endif; ?>
  3. smartinec
    Member
    Posted 12 months ago #

    I attempted that by putting a yarpp-template-widget.php in my template root, but it didn't get used. Also, there is no way to hide the title using a template. I ended up using jQuery to hide the div when the content says no posts. Not ideal, but working for now.

  4. Triple P
    Member
    Posted 12 months ago #

    The example above does "hide" the title. Did you select the template on the yarpp settings page, after you moved it to your theme folder?

  5. smartinec
    Member
    Posted 12 months ago #

    Thanks. I didn't even notice the template option in the widget config. It's working great now.

  6. Great! You can read more about this at http://mitcho.com/blog/projects/yarpp-3-templates/ .

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic