How to get the first or last 2 items in a collection

Is their a way to get the last two pages or the first two pages?

i wanna make a teaser on the start page where i wanna show the two latest projects.

Sure, you can use limit()

$page->children()->visible()->flip()->limit(2); //inverted order

// maybe use sort to sort by date or whatever

(You don’t seem to like the docs a lot, do you? :wink:)

i like it, but not always sure how to use some functions. Iam a almost typical designer :slight_smile:

1 Like