Underneath project pages I would like to display related news items. I would only like to show this snippet if related news items actually exist. So I am filtering for them like this:
<?php $posts = page('home')->children()->visible()->filterBy('project', $pageProject)->flip()->limit(4);
if (!empty($posts)): ?>
After this, I create the html for showing these items.
However, the second line in my code doesn’t seem to work, as it always shows the related news bit. It works fine for project which have related news items, by the way.
How do I properly check if the news items exist?