wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



get_category_parents › WordPress Function

Depuis1.2.0
Dépréciéen/a
get_category_parents ( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() )
Paramètres: (5)
  • (int) $category_id Category ID.
    Requis: Oui
  • (bool) $link Optional. Whether to format with link. Default false.
    Requis: Non
    Défaut: false
  • (string) $separator Optional. How to separate categories. Default '/'.
    Requis: Non
    Défaut: '/'
  • (bool) $nicename Optional. Whether to use nice name for display. Default false.
    Requis: Non
    Défaut: false
  • (array) $deprecated Not used.
    Requis: Non
    Défaut: array()
Retourne:
  • (string|WP_Error) A list of category parents on success, WP_Error on failure.
Défini(e) dans:
Codex:
Changelog:
  • 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 );
}