get_category_parents() WP 1.0
Retrieve category parents with separator.
Works based on: get_term_parents_list()
Basis of: get_the_category_list()
No Hooks.
Return
String/WP_Error. A list of category parents on success, WP_Error on failure.
Usage
get_category_parents( $category_id, $link, $separator, $nicename, $deprecated );
- $category_id(int) (required)
- Category ID.
- $link(true/false)
- Whether to format with link.
Default: false - $separator(string)
- How to separate categories.
Default: '/' - $nicename(true/false)
- Whether to use nice name for display.
Default: false - $deprecated(array)
- Not used.
Default: array()
Changelog
Since 1.2.0 | Introduced. |
Since 4.8.0 | The $visited parameter was deprecated and renamed to $deprecated. |
Code of get_category_parents() get category parents WP 5.6
function get_category_parents( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '4.8.0' );
}
$format = $nicename ? 'slug' : 'name';
$args = array(
'separator' => $separator,
'link' => $link,
'format' => $format,
);
return get_term_parents_list( $category_id, 'category', $args );
}