Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Taking your approach on designing things actually makes it fun, more natural, and overall easier.

— Dominik, Developer

Taxonomy Term Repository

To work with the Repository Term queries, use the following Facade:

use Statamic\Facades\Term;


Methods Description
all() Get all Terms
find($id) Get Term by id
findByUri($uri) Get Term by uri
query() Query Builder
make() Makes a new Term instance



Get a single term by its id

When getting a single term by its ID, the value of the $id parameter should be taxonomy_handle::term_id.

Term::query()->where('id', 'tags::123')->first();
// Or with the shorthand method

Get all tags

->where('taxonomy', 'tags')

Get all tags in a collection

->where('collection', 'blog')
->where('taxonomy', 'tags')

Get all tags in multiple collections

->where('taxonomy', 'tags')
->whereIn('collection', ['blog', 'news'])

Only include tags attached to entries

->where('taxonomy', 'tags')
->where('entries_count', '>=', 1);


Start by making an instance of a term with the make method.
You need at least a slug and the taxonomy.

$term = Term::make()->taxonomy('tags')->slug('my-term');

Data for a term is stored on a per site basis, even if you only are using a single site.

The method expects a site handle and an array of key-value pairs.

// Example for a single site
$term->dataForLocale('default', [
'mandalorian_code' => 'This Is The Value',

When using multi-site, you can pass different data to each site.

$term->dataForLocale('default', $data);
$term->dataForLocale('fr', $frenchData);

You may call additional methods on the term to customize it further.


Finally, save it. It'll return a boolean for whether it succeeded.

$term->save(); // true or false
HR: Section
Learn More!

There is more to learn more in these related articles:




HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →