插件开发文档

自定义分类法

💡 云策文档标注

概述

Taxonomy 是 WordPress 中用于分类或分组内容的机制,支持分层(父子关系)或扁平结构。开发者可以注册自定义 Taxonomies 以扩展默认分类系统。

关键要点

  • Taxonomy 存储在 term_taxonomy 数据库表中,允许注册自定义 Taxonomies。
  • Taxonomy 包含 Terms,作为分类的具体主题,存储在 terms 表中。
  • 示例:名为“Art”的 Taxonomy 可以有“Modern”和“18th Century”等 Terms。
  • 本章涵盖注册自定义 Taxonomies、从数据库检索内容以及公开渲染的方法。
  • WordPress 3.4 及更早版本有一个已弃用的“Links” Taxonomy。

📄 原文内容

A Taxonomy is a fancy word for the classification/grouping of things. Taxonomies can be hierarchical (with parents/children) or flat.

WordPress stores the Taxonomies in the term_taxonomy database table allowing developers to register Custom Taxonomies along the ones that already exist.

Taxonomies have Terms which serve as the topic by which you classify/group things. They are stored inside the terms table.

For example: a Taxonomy named “Art” can have multiple Terms, such as “Modern” and “18th Century”.

This chapter will show you how to register Custom Taxonomies, how to retrieve their content from the database, and how to render them to the public.

WordPress 3.4 and earlier had a Taxonomy named “Links” which was deprecated in WordPress 3.5.