Filter hook 'wp_update_term_parent'

in WP Core File wp-includes/taxonomy.php at line 3311

View Source

wp_update_term_parent

Filter Hook
Description
Filters the term parent. Hook to this filter to see if it will cause a hierarchy loop.

Hook Information

File Location wp-includes/taxonomy.php View on GitHub
Hook Type Filter
Line Number 3311

Hook Parameters

Type Name Description
int $parent_term ID of the parent term.
int $term_id Term ID.
string $taxonomy Taxonomy slug.
array $parsed_args An array of potentially altered update arguments for the given term.
array $args Arguments passed to wp_update_term().

Usage Examples

Basic Usage
<?php
// Hook into wp_update_term_parent
add_filter('wp_update_term_parent', 'my_custom_filter', 10, 5);

function my_custom_filter($parent_term, $term_id, $taxonomy, $parsed_args, $args) {
    // Your custom filtering logic here
    return $parent_term;
}

Source Code Context

wp-includes/taxonomy.php:3311 - How this hook is used in WordPress core
<?php
3306  	 * @param int    $term_id     Term ID.
3307  	 * @param string $taxonomy    Taxonomy slug.
3308  	 * @param array  $parsed_args An array of potentially altered update arguments for the given term.
3309  	 * @param array  $args        Arguments passed to wp_update_term().
3310  	 */
3311  	$parent = (int) apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args );
3312  
3313  	// Check for duplicate slug.
3314  	$duplicate = get_term_by( 'slug', $slug, $taxonomy );
3315  	if ( $duplicate && $duplicate->term_id !== $term_id ) {
3316  		/*

PHP Documentation

<?php
/**
	 * Filters the term parent.
	 *
	 * Hook to this filter to see if it will cause a hierarchy loop.
	 *
	 * @since 3.1.0
	 *
	 * @param int    $parent_term ID of the parent term.
	 * @param int    $term_id     Term ID.
	 * @param string $taxonomy    Taxonomy slug.
	 * @param array  $parsed_args An array of potentially altered update arguments for the given term.
	 * @param array  $args        Arguments passed to wp_update_term().
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/taxonomy.php
Related Hooks

Related hooks will be displayed here in future updates.