get_category_parents( int $id, bool $link = false, string $separator = '/', bool $nicename = false, array $deprecated = array() )

Retrieve category parents with separator.


Parameters

$id

(Required) Category ID.

$link

(Optional) Whether to format with link.

Default value: false

$separator

(Optional) default is '/'. How to separate categories.

Default value: '/'

$nicename

(Optional) Whether to use nice name for display.

Default value: false

$deprecated

(Optional) Not used.

Default value: array()


Return

(string|WP_Error) A list of category parents on success, WP_Error on failure.


Source

File: wp-includes/category-template.php

function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) {

	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, 'WP-4.8.0' );
	}

	$format = $nicename ? 'slug' : 'name';

	$args = array(
		'separator' => $separator,
		'link'      => $link,
		'format'    => $format,
	);

	return get_term_parents_list( $id, 'category', $args );
}


Changelog

Changelog
Version Description
WP-4.8.0 The $visited parameter was deprecated and renamed to $deprecated.
WP-1.2.0 Introduced.