內容簡介
此外掛實現了分類術語的元數據基礎設施,因此您可以向標籤、類別和其他分類術語中添加自定義元數據(按鍵)。大部分代碼來自於sirzooro提交到 WordPress Core Trac的代碼。插件的其餘部分僅是一些單純的補丁,以使其在不修改核心的情況下運作。它不實現任何用於分類術語元數據的UI。
該插件實現了以下功能,您可以使用它們來構建自己的自定義 UI 和顯示代碼:
add_term_meta($term_id, $meta_key, $meta_value, $unique):向術語添加元數據字段。
@param int $term_id 文章 ID。
@param string $key 元數據名稱。
@param mixed $value 元數據值。
@param bool $unique 可選,默認為false。是否不應添加相同的鍵。
@return bool 失敗時為false。成功時為true。
delete_term_meta($term_id, $meta_key, $meta_value):從術語中刪除匹配條件的元數據。您可以基於鍵或鍵和值進行匹配。基於鍵和值進行刪除,將避免刪除具有相同鍵的重複元數據。如果需要,它還允許刪除匹配鍵的所有元數據。
@param int $term_id 術語 ID
@param string $meta_key 元數據名稱。
@param mixed $meta_value 可選。元數據值。
@return bool 失敗時為false。成功時為true。
get_term_meta($term_id, $key, $single):為術語檢索元數據字段。
@param int $term_id 術語 ID。
@param string $key 要檢索的元數據鍵。
@param bool $single 是否返回單個值。
@return mixed 如果$single為false,則會返回一個數組。如果$single是true,那麼它將是元數據字段的值。
update_term_meta($term_id, $meta_key, $meta_value, $prev_value):基於術語ID更新術語元數據字段。使用$prev_value參數區分具有相同鍵和術語ID的元數據字段。如果術語的元數據字段不存在,它將被添加。
@param int $term_id 術語 ID。
@param string $key 元數據鍵。
@param mixed $value 元數據值。
@param mixed $prev_value 可選。在刪除之前檢查的先前值。
@return bool 失敗時為false,成功時為true。
此外掛的開發受到了麻省理工學院莎士比亞項目的支持。
外掛標籤
開發者團隊
原文外掛簡介
This plugin implements the metadata infrastructure for taxonomy terms, so you can add custom metadata (by key) to tags, categories, and other taxonomies. The majority of the code is from sirzooro’s submission to the WordPress Core Trac. The rest of the plugin is simply some hacky glue to make this work without modifying the Core. It does not implement any UI for taxonomy term metadata.
The plugin implements the following functions, from which you can build your own custom UI and display code:
add_term_meta($term_id, $meta_key, $meta_value, $unique): Add meta data field to a term.
@param int $term_id Post ID.
@param string $key Metadata name.
@param mixed $value Metadata value.
@param bool $unique Optional, default is false. Whether the same key should not be added.
@return bool False for failure. True for success.
delete_term_meta($term_id, $meta_key, $meta_value): Remove metadata matching criteria from a term. You can match based on the key, or key and value. Removing based on key and value, will keep from removing duplicate metadata with the same key. It also allows removing all metadata matching key, if needed.
@param int $term_id term ID
@param string $meta_key Metadata name.
@param mixed $meta_value Optional. Metadata value.
@return bool False for failure. True for success.
get_term_meta($term_id, $key, $single): Retrieve term meta field for a term.
@param int $term_id Term ID.
@param string $key The meta key to retrieve.
@param bool $single Whether to return a single value.
@return mixed Will be an array if $single is false. Will be value of meta data field if $single is true.
update_term_meta($term_id, $meta_key, $meta_value, $prev_value): Update term meta field based on term ID. Use the $prev_value parameter to differentiate between meta fields with the same key and term ID. If the meta field for the term does not exist, it will be added.
@param int $term_id Term ID.
@param string $key Metadata key.
@param mixed $value Metadata value.
@param mixed $prev_value Optional. Previous value to check before removing.
@return bool False on failure, true if success.
Development of this plugin was supported by the Massachusetts Institute of Technology Shakespeare Project.
