Plug in is great! I'm trying to set it up so that if there aren't any related posts some default text is shown.
my goal is:
- if there are related posts:
- show this title and all the related posts (this part is working great)
- if there aren't any related posts:
- show a different title and some set links
I found it!
Use this code if you want default text to show if there are no related links chosen with this plugin:
<?php $related_links = get_related_links(true);
if ($related_links) {
?>
<?php foreach ($related_links as $link): ?>
<p><strong><?php echo $link["type"]; ?></strong> <br>
<a href="<?php echo $link["url"]; ?>"><?php echo $link["title"]; ?></a></p>
<?php endforeach; ?>
<?php } else { ?>
<p>display this default text</p>
<?php } ?>
yeah. or check the count of the array. btw: the trueargument in get_related_links is wrong.
$related_links = get_related_links();
if(count(related_links) == 0)
{
// no links
}
else
{
// has links
}