How to get category link without a database query

It’s down to how you’re using get_term_link() – since you’re passing a slug, WordPress can’t locate the term in it’s internal cache (terms are indexed by ID), so it grabs it directly from the db.

To use the cache, pass the ID. Better yet, pass just the object:

get_term_link( $category ); // No need for taxonomy param when you pass a term object

Leave a Comment