$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - What's the difference between "parent" and "category_parent" in a WP_Te|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - What's the difference between "parent" and "category_parent" in a WP_Te

matteradmin10PV0评论

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
    )

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
    )
Share Improve this question asked Dec 4, 2018 at 22:45 scott8035scott8035 2302 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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.

Post a comment

comment list (0)

  1. No comments so far