WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the Wordpress related plugin : http://wordpress.org/extend/plugins/related/

Which uses the following markup to call the plugin:

<?php echo $related->show(get_the_ID()); ?>

I would like to add a title and a division around the plugin... but would only like this to display if there is a related post/page. How should I modify the code?

This is the result I would like to see, but only when there is related content:

<div class="related"><strong>Related products</strong><br />
<?php echo $related->show(get_the_ID()); ?>
share|improve this question
up vote 2 down vote accepted

I don't know for sure if this would work but this is where I'd start:

<?php $related_content = $related->show(get_the_ID()); ?>
<?php if($related_content): ?>
    <div class="related"><strong>Related products</strong><br />
        <?php echo $related_content; ?>
<?php endif; ?>
share|improve this answer
I'll give it a shot and let you know! – Vince Pettit Feb 24 '12 at 9:26
Works perfectly, thanks! – Vince Pettit Feb 24 '12 at 9:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.