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;
} );