A WordPress-centric search engine for devs and theme authors



get_category_parents ›

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

Retrieve category parents with separator.



Source

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