#21875 closed enhancement (wontfix)
get_categories orderby random
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Taxonomy | Version: | 3.4.2 |
| Severity: | trivial | Keywords: | |
| Cc: | me@… |
Description
There's no option to order the categories in the get_categories function by random..
Maybe you can include it in the next version.
get_posts etc. has got this option.
Change History (4)
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
Have used the shuffle function, but think, that my way brings a better performance..
Replying to Ninos Ego:
Have used the shuffle function, but think, that my way brings a better performance..
When you push randomization to SQL, it means we can't actually cache the results, as they're supposed to be random. get_posts() does pagination, which is why we push it to SQL — you need only X of Y posts, but a random X of them.
But get_terms(), as scribu said, isn't paginated. Thus, letting the query be cached, then shuffling them on your own, makes more sense.

Unlike get_posts(), get_categories() doesn't have pagination, so you can just use shuffle():