What's the difference between "parent" and "category_parent" in a WP_Term object? For example:

[1] => WP_Term Object
        [term_id] => 24
        [name] => Essential Oils
        [slug] => essential-oils
        [term_group] => 0
        [term_taxonomy_id] => 24
        [taxonomy] => category
        [description] => 
        [parent] => 22
        [count] => 14
        [filter] => raw
        [cat_ID] => 24
        [category_count] => 14
        [category_description] => 
        [cat_name] => Essential Oils
        [category_nicename] => essential-oils
        [category_parent] => 22

The properties prefixed with category_ or cat_ are there for backwards compatibility.

Taxonomies and terms were introduced in WordPress 2.3 (11 years ago) and categories were converted into a taxonomy at that time. Prior to this categories had their own properties (the ones with the aforementioned prefixes).

For backwards compatibility, the _make_cat_compat() function is used in some places to add the old properties to categories. You can see from the source that all it does is copy the standard term properties to the old names, so parent and category_parent will always have the same value, as an example.

In 2018 you should avoid using the category-specific properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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