So here’s some info for any other people with this issue.
get_terms
will not use the number
parameter under certain conditions, such as if you pass in a parent
parameter or if the hierarchical
parameter is true
. In these cases I have tried two workarounds, neither very good.
-
You can call
get_terms
then do anarray_slice
on the results afterwards. However if you have a ton of taxonomies then WordPress can run out of memory during theget_terms
call, which was my original issue. -
You can hook into the filter
terms_clauses
and force theget_terms
call to use a LIMIT in its sql call. However this applies to all calls ofget_terms
across WordPress and not just the one in my custom code, and I don’t want to cause unintended consequences.