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



get_category_parents ›

Since1.2.0
已弃用n/a
get_category_parents ( $id, $link = false, $separator = '/', $nicename = false, $deprecated = array() )
参数: (5)
  • (int) $id Category ID.
    Required: Yes
  • (bool) $link Optional, default is false. Whether to format with link.
    Required: No
    默认: false
  • (string) $separator Optional, default is '/'. How to separate categories.
    Required: No
    默认: '/'
  • (bool) $nicename Optional, default is false. Whether to use nice name for display.
    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

Retrieve category parents with separator.



源码

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