WordPress.org

Support

Support » Plugins and Hacks » Yet Another Related Posts Plugin (YARPP) » [Plugin: Yet Another Related Posts Plugin] Hide widget when no related content

[Plugin: Yet Another Related Posts Plugin] Hide widget when no related content

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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; ?>

    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.

    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?

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

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] Hide widget when no related content’ is closed to new replies.
Skip to toolbar