WordPress at a glance

get_category_parents() WP 1.0

Retrieve category parents with separator.

  • Since 4.8.0 The $visited parameter was deprecated and renamed to $deprecated.
Is the basis for: get_the_category_list()
Works based on: get_term_parents_list()

No Hooks.

Return

String/WP_Error. A list of category parents on success, WP_Error on failure.

Usage

get_category_parents( $id, $link, $separator, $nicename, $deprecated );
$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()

Code of get_category_parents: wp-includes/category-template.php VER 5.0.1

<?php
function get_category_parents( $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( $id, 'category', $args );
}

Related Functions

From tag: Relations (of posts terms...)

More from category: Categories

No comments
    Hello, !     Log In . Register