_post_format_get_term()
云策文档标注
概述
_post_format_get_term() 是一个 WordPress 内部函数,用于从 get_term() 创建的术语对象中移除文章格式前缀,并更新其名称属性为可读的翻译版本。
关键要点
- 函数接受一个术语对象作为参数,并返回处理后的对象。
- 通过检查术语对象的 slug 属性,移除 'post-format-' 前缀,并使用 get_post_format_string() 函数获取翻译后的名称。
- 该函数自 WordPress 3.1.0 版本引入,主要用于内部处理文章格式术语。
代码示例
function _post_format_get_term( $term ) {
if ( isset( $term->slug ) ) {
$term->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) );
}
return $term;
}
原文内容
Remove the post format prefix from the name property of the term object created by get_term() .
Parameters
$termobjectrequired
Source
function _post_format_get_term( $term ) {
if ( isset( $term->slug ) ) {
$term->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) );
}
return $term;
}
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |