Summery Summery

Sanitize Term all fields.

Syntax Syntax

sanitize_term( array|object $term, string $taxonomy, string $context = 'display' )

Description Description

Relies on sanitize_term_field() to sanitize the term. The difference is that this function will sanitize all fields. The context is based on sanitize_term_field().

The $term is expected to be either an array or an object.

Parameters Parameters


(Required) The term to check.


(Required) The taxonomy name to use.


(Optional) Context in which to sanitize the term. Accepts 'edit', 'db', 'display', 'attribute', or 'js'. Default 'display'.

Default value: 'display'

Return Return

(array|object) Term with all fields sanitized.

Source Source

File: wp-includes/taxonomy.php

 * Check if a term is an ancestor of another term.
 * You can use either an ID or the term object for both parameters.
 * @since 3.4.0
 * @param int|object $term1    ID or object to check if this is the parent term.
 * @param int|object $term2    The child term.
 * @param string     $taxonomy Taxonomy name that $term1 and `$term2` belong to.
 * @return bool Whether `$term2` is a child of `$term1`.
function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
	if ( ! isset( $term1->term_id ) ) {
		$term1 = get_term( $term1, $taxonomy );
	if ( ! isset( $term2->parent ) ) {
		$term2 = get_term( $term2, $taxonomy );

	if ( empty( $term1->term_id ) || empty( $term2->parent ) ) {
		return false;
	if ( $term2->parent === $term1->term_id ) {
		return true;


Changelog Changelog

Version Description
2.3.0 Introduced.


Leave a Reply