Defining a post or term language

I’m going to try to set this out in stages, so people can take issue with each or any particular stage. 🙂

WordPress provides no way to define a locale for posts and terms. This means that plugin authors must define one, which adds complexity to all content queries during the actions and filters run for each request, and may also add complexity to the data structures. The lack of a built-in API for locale definition additionally complicates saving content, though that is significantly less impactful that the content retrieval issues.


  • WPML stores locale in an additional table, and this table is joined to allow retrieval of the content in the correct language
  • Polylang uses a taxonomy to store locale, and this taxonomy is referenced in queries for the content
  • Babble uses a parallel post type or taxonomy for each language, which complicates the data structure

Each of the above solutions is further unique to that particular plugin, which means that any other plugin author, theme author, or developer, who wants to act on content of a given type is presented with a complications specific to each; what language is the post in, what post type represents the language for this post, etc.

In broad outline, I propose:

  • WordPress core provides an API to allow a locale to be defined for a post or term, the locale should default to “unspecified”, and data structure(s) to store this
  • WordPress provides an API to allow content queries, for posts and terms, to request content with a specific locale

Currently I envisage the implementation as:

  • wp_insert_post and related functions accept a parameter to allow a locale to be defined for a post or term, the locale should default to “no locale”
  • The locale designation is stored in an additional column in wp_posts and wp_terms respectively
  • wp_query allows an additional parameter to specify content from a particular locale

One thing which has occurred to me: If some content gets assigned a locale, but other content does not, (e.g. if a multi-locale aware plugin has been active and is not inactive) what content should be retrieved? It’s possible the desired behaviour for a content query on a site which has no interest in multiple locales is different to that of a site which is aware of multiple locales.