On this page
get_category_parents( int $category_id, bool $link = false, string $separator = '/', bool $nicename = false, array $deprecated = array() ): string|WP_Error
Retrieves category parents with separator.
Parameters
$category_idint Required-
Category ID.
$linkbool Optional-
Whether to format with link.
Default:
false $separatorstring Optional-
How to separate categories. Default
'/'.Default:
'/' $nicenamebool Optional-
Whether to use nice name for display.
Default:
false $deprecatedarray Optional-
Not used.
Default:
array()
Return
string|WP_Error A list of category parents on success, WP_Error on failure.
Source
File: wp-includes/category-template.php. View all references
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 );
}
Related
Uses
| Uses | Description |
|---|---|
| get_term_parents_list() wp-includes/category-template.php | Retrieves term parents with separator. |
| _deprecated_argument() wp-includes/functions.php | Marks a function argument as deprecated and inform when it has been used. |
Used By
| Used By | Description |
|---|---|
| get_the_category_list() wp-includes/category-template.php | Retrieves category list for a post in either HTML list or custom format. |
| get_permalink() wp-includes/link-template.php | Retrieves the full permalink for the current post or post ID. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_category_parents