<?php
global $related_posts_thumbnails;
if ($related_posts_thumbnails->get_html()) { ?>
<div id="relatedproducts">
<h1>Related Products</h1>
<?php get_related_posts_thumbnails() ?>
</div>
<?php } ?>
A quick look at the get_related_posts_thumbnails()
shows that it is simply echoing the HTML returned from the get_html()
method of the $related_posts_thumbnails
object. By checking the returned HTML first, you can make sure it is not an empty string (or any falsy value).
Note for the plugin author: picking the name get_related_posts_thumbnails()
and making it echo the output is quite unintuitive. Other WordPress functions use the get_
prefix for functions that return data, and leave it out to echo it. For example: get_bloginfo('url')
vs bloginfo('url')
.