Although this is not really FacetWP-related, we often get this question. With the bonus question of how to add a term heading above each group of posts sharing a term/category.

The orderby parameter in WP_Query can be used to order by many things, including custom fields. But unfortunately, ordering by taxonomy terms or categories is not directly possible.

We wrote this tutorial that explores two different workarounds to accomplish this. Both approaches order a query by terms or categories in a custom WP_Query template, then (optionally) output a heading above each group of posts in a term/category, and wrap each group in a container element (for styling).

Both workarounds are quite complicated to implement and may not work in all situations. So if you can avoid this, we recommend using another built-in orderby parameter.

See also

Last updated: December 18, 2025