我原以为这是术语meta,但这似乎不正确。
为了便于说明,我创建了一个名为“Test”的类别,其中有一个“Test”的slug。
我正在用以下内容更新其term\\u meta:
update_term_meta( 64, \'test_meta\', \'asdfasdf\' );
这与其他元键/值一起出现在termmeta表中:
get\\u term(64)返回以下内容:
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
(
)
)
为什么是
[meta]
空的
get_term_meta(64)
按预期返回:
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
)
)
最合适的回答,由SO网友:Sally CJ 整理而成
查看source, 那个meta
属性不是中的标准属性WP_Term
对象
但是,插件/主题可以使用get_term
或get_{taxonomy}
过滤器:
add_filter( \'get_term\', function( $term ){
$term->meta = get_term_meta( $term->term_id ); // all metadata
return $term;
} );