get_category_parents

函数


get_category_parents ( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() )
参数
  • (int)
    $category_id
    Category ID.
    Required:
  • (bool)
    $link
    Optional. Whether to format with link. Default false.
    Required:
    Default: false
  • (string)
    $separator
    Optional. How to separate categories. Default ‘/’.
    Required:
    Default: ‘/’
  • (bool)
    $nicename
    Optional. Whether to use nice name for display. Default false.
    Required:
    Default: false
  • (array)
    $deprecated
    Not used.
    Required:
    Default: array()
返回值
  • (string|WP_Error) A list of category parents on success, WP_Error on failure.
定义位置
  • wp-includes/category-template.php
    , line 47
引入
1.2.0
弃用

Retrieves category parents with separator.

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 );
}