Taxonomy term or custom field

For a few years I have referred to answer on WPSE by scribu about choice between going with taxonomy term or custom field for data in WordPress. That answer boils down to how many posts will share same value and does it need to be used in filtering.

Over time I had picked quite a few more nuances and decided to round them up.

Terms & fields differences

Issue Term Field
Semantics Group of posts Attribute of individual post
Reuse Shared between posts Distinct individual values
Hierarchy Native Absent
Permalinks Native Absent
Descriptions Native Absent
Meta Easily added Absent
Data sets Absent Multiple values; serialized
Filtering Limited Extensive
Ordering Absent, discouraged Native
SQL Complex (three tables) Simple (one table)

Takeaways

The semantic choice is more or less clear:

  • taxonomy terms serve better for organization of content on site
  • custom fields serve better for data storage and retrieval

In practice there is often need to satisfy combination of issues, neither of the two addresses in full.

In such cases the common approaches are:

  • supplementing missing functionality with custom rewrite rules and SQL queries
  • mirroring by duplicating or otherwise overlapping the data between the two

Related Posts