A WordPress agency builds a recipe site with a cuisine taxonomy. At launch, there are 12 terms — Italian, Mexican, etc. Two years later there are 14,000 because every ingredient became a term. The taxonomy archive page now takes 8 seconds to load and the admin term-list page times out. WordPress taxonomies work fine at small scale and become a performance question at scale. The shape of the data — hierarchy depth, term count, term_meta volume — determines whether the site stays fast.
What’s happening
WordPress stores taxonomy data in three tables: wp_terms (the term names), wp_term_taxonomy (the taxonomy-term mapping, with parent IDs for hierarchy), and wp_term_relationships (which posts have which terms). A single post with 5 categories and 20 tags generates 25 rows in wp_term_relationships. A site with 100k posts averaging 10 terms each has a million rows there.
The query pattern is post_id IN (SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (X, Y, Z)). With proper indexes (which WordPress provides by default), this is fast for hundreds of thousands of rows. Without them — or with a custom query that joins differently — it isn’t.
The hierarchy is the second performance vector. A 5-level deep taxonomy with 10,000 terms generates expensive walker queries when the admin term-list renders the tree. WordPress doesn’t paginate that view past 100 terms — you get the whole tree on every load.
Term meta (the wp_termmeta table) is the third. Each get_term_meta() call generates a query unless the cache is warm. Listing 500 terms with get_term_meta for each is 500 queries.
How to verify
Inventory taxonomy data on a site:
wp eval '
foreach (get_taxonomies(["public" => true], "objects") as $tax) {
$count = wp_count_terms(["taxonomy" => $tax->name, "hide_empty" => false]);
echo sprintf("%-20s hierarchy:%s count:%d\n", $tax->name, $tax->hierarchical ? "y" : "n", $count);
}
'
Anything over a few thousand non-hierarchical terms or a few hundred hierarchical terms with depth > 3 is at scale and worth a perf check.
For specific query timing:
wp db query "
SELECT COUNT(*) as rel_count FROM wp_term_relationships;
SELECT COUNT(*) as term_count FROM wp_terms;
SELECT taxonomy, COUNT(*) as cnt FROM wp_term_taxonomy GROUP BY taxonomy ORDER BY cnt DESC;
"
Profile a slow taxonomy archive request with Query Monitor active. Look for WP_Term_Query or Tax_Query lines taking > 100ms.
What to do
The design decisions that keep taxonomies fast at scale.
-
Pick hierarchy intentionally. Hierarchical taxonomies (
hierarchical => true) are like categories — parent terms, tree structure, checkbox UI in the editor. Non-hierarchical are like tags — flat, comma-separated input. Don’t make a taxonomy hierarchical “in case.” A flat taxonomy with parent terms expressed as a separate taxonomy (“brand” parent, “model” child as two flat taxonomies) is sometimes the right design. -
Limit depth to 3-4 levels at most. Beyond that, the term hierarchy walker becomes the bottleneck on every admin term-list page load.
-
Avoid storing high-cardinality data as terms. If a “color” taxonomy is going to have 5,000 entries because someone uploads RGB hex codes as terms, that’s not a taxonomy — that’s a custom field, or a custom table. Taxonomies are for grouping and filtering, not for arbitrary string storage.
-
For tag-like data that will exceed 10k terms, register the taxonomy with
update_count_callback => '_update_post_term_count'(the default) but disable the front-end archive (has_archive => false). The archive query is what hurts; the data structure itself is fine. -
Use
wp_get_object_terms()with caching for batch operations. The function reads from cache when warm; for cold-cache loops, prime with_prime_term_caches():
$post_ids = wp_list_pluck(get_posts(['posts_per_page' => 100]), 'ID');
_prime_post_caches($post_ids, false, true); // includes terms
foreach ($post_ids as $pid) {
$terms = wp_get_post_terms($pid, 'cuisine'); // hits cache
}
- Don’t
get_term_meta()in a loop. Cache it:
$terms = get_terms(['taxonomy' => 'cuisine', 'hide_empty' => false]);
update_termmeta_cache(wp_list_pluck($terms, 'term_id'));
foreach ($terms as $term) {
$custom = get_term_meta($term->term_id, 'icon', true); // now hits cache
}
- For archive pages with many terms, set a
query_varthat supports pagination:
'query_var' => 'cuisine',
'rewrite' => ['slug' => 'cuisine', 'with_front' => false, 'hierarchical' => true],
'show_in_rest' => true,
Without query_var, the archive can’t paginate cleanly past WordPress’s default.
- For very large taxonomies (50k+ terms), consider whether the data should be a custom post type instead —
wp_postspaginates and indexes better thanwp_termsfor browse-style UI. The conversion is one-time pain for permanent performance gain.
For the related CPT design decisions, see WordPress custom post types best practices. Stack Harbor’s Enterprise WordPress practice audits taxonomy design as part of large-content-site onboarding. If a site’s taxonomy archive is the slowest page and reindexing didn’t help, we can do the audit.