admin管理员组文章数量:1425245
I thought it would be term meta but that doesn't seem to be correct.
For illustration I've created a category named "Test" with a slug of "test".
I'm updating its term_meta with:
update_term_meta( 64, 'test_meta', 'asdfasdf' );
This appears in the termmeta table along with other meta keys/values:
get_term(64) returns this:
WP_Term Object ( [term_id] => 64 [name] => Test [slug] => test [term_group] => 0 [term_taxonomy_id] => 64 [taxonomy] => category [description] => [parent] => 0 [count] => 0 [filter] => raw [meta] => Array ( ) )
Why is [meta]
empty?
get_term_meta(64)
returns as expected:
Array
(
[headline] => Array
(
[0] =>
)
[intro_text] => Array
(
[0] =>
)
[display_title] => Array
(
[0] => 0
)
[display_description] => Array
(
[0] => 0
)
[doctitle] => Array
(
[0] =>
)
[description] => Array
(
[0] => Meta desc
)
[keywords] => Array
(
[0] => someMetaKeyword
)
[layout] => Array
(
[0] =>
)
[noindex] => Array
(
[0] => 0
)
[nofollow] => Array
(
[0] => 0
)
[noarchive] => Array
(
[0] => 0
)
[test_meta] => Array
(
[0] => asdfasdf
)
)
I thought it would be term meta but that doesn't seem to be correct.
For illustration I've created a category named "Test" with a slug of "test".
I'm updating its term_meta with:
update_term_meta( 64, 'test_meta', 'asdfasdf' );
This appears in the termmeta table along with other meta keys/values:
get_term(64) returns this:
WP_Term Object ( [term_id] => 64 [name] => Test [slug] => test [term_group] => 0 [term_taxonomy_id] => 64 [taxonomy] => category [description] => [parent] => 0 [count] => 0 [filter] => raw [meta] => Array ( ) )
Why is [meta]
empty?
get_term_meta(64)
returns as expected:
Array
(
[headline] => Array
(
[0] =>
)
[intro_text] => Array
(
[0] =>
)
[display_title] => Array
(
[0] => 0
)
[display_description] => Array
(
[0] => 0
)
[doctitle] => Array
(
[0] =>
)
[description] => Array
(
[0] => Meta desc
)
[keywords] => Array
(
[0] => someMetaKeyword
)
[layout] => Array
(
[0] =>
)
[noindex] => Array
(
[0] => 0
)
[nofollow] => Array
(
[0] => 0
)
[noarchive] => Array
(
[0] => 0
)
[test_meta] => Array
(
[0] => asdfasdf
)
)
Share
Improve this question
asked Jun 15, 2019 at 18:14
Ken DeWittKen DeWitt
133 bronze badges
1 Answer
Reset to default 2Looking at the source, that meta
property isn't a standard property in the WP_Term
object.
However, a plugin/theme can add custom properties to the object using the get_term
or get_{taxonomy}
filter:
add_filter( 'get_term', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );
本文标签: What is the quotmetaquot key in WPTerm Object
版权声明:本文标题:What is the "meta" key in WP_Term Object? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745398628a2656933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论