<ul>
<?php foreach (array_slice($items, 0, 3) as $item): ?>
<?php if (!isset($item->story)): ?> <!-- hide story updates -->
<li>
<?php if (isset($item->message)) echo $item->message; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
I am displaying a news feed, and only want to display the items without a story update. So i am using !isset to check if a story item is present, and hide the item if it is.
This works perfectly, but now I am trying to display 3 results in the feed, but i think the story items are still being counted in the foreach, so when the last 3 updates are story items, nothing displays in the feed.
I have read this question which looks like what I am trying to do, but I dont understand where he has got the $elementkey variable from, and what it does?
How do I remove the item from the foreach, and remove its count so 3 items will display?