Summery Summery

Checks the given subset of the term hierarchy for hierarchy loops.

Syntax Syntax

wp_check_term_hierarchy_for_loops( int $parent, int $term_id, string $taxonomy )

Description Description

Prevents loops from forming and breaks those that it finds.

Attached to the ‘wp_update_term_parent’ filter.

Parameters Parameters


(Required) term_id of the parent for the term we're checking.


(Required) The term we're checking.


(Required) The taxonomy of the term we're checking.

Return Return

(int) The new parent for the term.

Source Source

File: wp-includes/taxonomy.php

			$numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) );
			if ( in_array( $object_term->term_id, $numeric_strs, true ) ) {
				return true;

			if ( in_array( $object_term->name, $strs, true ) ) {
				return true;
			if ( in_array( $object_term->slug, $strs, true ) ) {
				return true;

	return false;

 * Determine if the given object type is associated with the given taxonomy.
 * @since 3.0.0
 * @param string $object_type Object type string.
 * @param string $taxonomy    Single taxonomy name.
 * @return bool True if object is associated with the taxonomy, otherwise false.
function is_object_in_taxonomy( $object_type, $taxonomy ) {
	$taxonomies = get_object_taxonomies( $object_type );
	if ( empty( $taxonomies ) ) {


Changelog Changelog

Version Description
3.1.0 Introduced.


Leave a Reply