wpseek.com
A WordPress-centric search engine for devs and theme authors



get_category_parents › WordPress Function

Since1.2.0
Deprecatedn/a
get_category_parents ( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() )
Parameters: (5)
  • (int) $category_id Category ID.
    Required: Yes
  • (bool) $link Optional. Whether to format with link. Default false.
    Required: No
    Default: false
  • (string) $separator Optional. How to separate categories. Default '/'.
    Required: No
    Default: '/'
  • (bool) $nicename Optional. Whether to use nice name for display. Default false.
    Required: No
    Default: false
  • (array) $deprecated Not used.
    Required: No
    Default: array()
Returns:
  • (string|WP_Error) A list of category parents on success, WP_Error on failure.
Defined at:
Codex:
Change Log:
  • 4.8.0

Retrieves category parents with separator.



Source

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