1

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:

data in termmeta table

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
    )

)

1 Answer 1

2

Looking 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;
} );
1
  • 1
    Using 2015 theme with only ACF and the plugin I'm working on active. Tried on a fresh site with the same theme and plugins and I'm not seeing the 'meta' property. Something must be happening on the first site I'm not aware of. Thanks!
    – Ken DeWitt
    Commented Jun 16, 2019 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.