diff --git a/content/collections/docs/4-to-5.md b/content/collections/docs/4-to-5.md index bf1b51569..065791234 100644 --- a/content/collections/docs/4-to-5.md +++ b/content/collections/docs/4-to-5.md @@ -377,6 +377,53 @@ If you use this `{{ glide filename="" }}` parameter, you'll need to remove remov If you are hot-linking to any images rendered with manually set filenames in this way, you'll also need to correct those links. +### Entries may now only be queried by a single status +**Affects any apps or addons filtering entries by `status`.** + +Previously, when querying entries, you could use *any* condition to filter entries. + +However, in v5, as part of improvements to how statuses work behind the schenes, statuses can now only be filtered using the `is` / `equals` conditions, and the `whereStatus` query method. Some examples: + +Collection tag: +```antlers +{{ collection:blog status:in="published" }} {{# [tl! --] #}} +{{ collection:blog status:is="published" }} {{# [tl! ++] #}} +``` + +PHP: +```php +Entry::query() + ->where('collection', 'blog') + ->where('status', 'published') // [tl! --] + ->whereStatus('published') // [tl! ++] + ->get(); +``` + +REST API: +```php +/api/collections/blog/entries?filter[status:in]=published // [tl! --] +/api/collections/blog/entries?filter[status]=published // [tl! ++] +``` + +GraphQL API: +```graphql +{ + entries( + collection: "blog" + filter: { + status: { in: "published" } #[tl! --] + status: "published" #[tl! ++] + } + ) { + data { + title + } + } +} +``` + +Let us know if you need to query by multiple statuses by opening a [GitHub issue](https://github.com/statamic/cms). + ## Zero impact changes These are items that you can completely ignore. They are suggestions on how to improve your code using newly added features. diff --git a/content/collections/tags/collection.md b/content/collections/tags/collection.md index 45e211c7b..0bad85606 100644 --- a/content/collections/tags/collection.md +++ b/content/collections/tags/collection.md @@ -214,14 +214,8 @@ There are several different ways to use this filtering parameter. They are expla By default, only `published` entries are included. Entries can be queried against `draft`, `scheduled`, or `expired` status with [conditions](#conditions) on `status` like this: ``` -// Include draft entries -{{ collection:blog status:in="published|draft" }} - -// Only include expired entries -{{ collection:blog status:is="expired" }} - -// Exclude published entries -{{ collection:blog status:not_in="published" }} +// Only include published entries +{{ collection:blog status:is="published" }} ``` :::tip