wpseek.com
WordPress开发者和主题制作者的搜索引擎



get_category_parents › WordPress Function

Since1.2.0
已弃用n/a
get_category_parents ( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() )
参数: (5)
  • (int) $category_id Category ID.
    Required: Yes
  • (bool) $link Optional. Whether to format with link. Default false.
    Required: No
    默认: false
  • (string) $separator Optional. How to separate categories. Default '/'.
    Required: No
    默认: '/'
  • (bool) $nicename Optional. Whether to use nice name for display. Default false.
    Required: No
    默认: false
  • (array) $deprecated Not used.
    Required: No
    默认: array()
返回:
  • (string|WP_Error) A list of category parents on success, WP_Error on failure.
定义在:
文档:
Change Log:
  • 4.8.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 );
}