Hi everyone. I was wondering how I can achieve the same result of $page->offset() but with tags. I want to pass the first tag.
I havenβt tested this, but canβt you limit()
the tags?
$tag = $page->tags()->limit(1);
1 Like
You need to transform your tags to an array first using split
Tags() is just a field.
Once you have your array you can use limit(1) or even easier first()
1 Like
You canβt use collection methods on an array, but the methods from the βAβ class will do the job in this case:
$tags = $page->tags()->split(',');
$first = a::first($tags);
2 Likes
Thank you all for your answers!
Best regards!