How can I get Entries with a certain Taxonomy Term attached in Laravel? #6278
Unanswered
mikemike
asked this question in
Troubleshooting
Replies: 1 comment 2 replies
-
Terms dont have ids, they have slugs... so you should be able to do Alternatively you can come at it the other way, and get the Term using the Term::query facade, and then get the entries of the term. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the
Entry
Facade to get entries from Statamic in Laravel (I'm not using Antlers). I have a simple concept of News posts with Categories. When a user selects a category I want to get all entries that are tagged with that category.My collection is called 'news'.
My Taxonomy is called 'news_categories'.
This is attached to the collection using a field called 'categories'.
Below is my code:
This returns an empty collection every time a category is selected (eg whenever
$request->category
is set).I can't find any documentation on
whereTaxonomy
so I've had to go digging in Statamic's code to find it.Any help greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions