get_term_to_edit() WordPress Function

The get_term_to_edit() function is used to retrieve a term object for editing. This function is useful for customizing the editing interface for a custom taxonomy.

get_term_to_edit( int|object $id, string $taxonomy ) #

Sanitizes term for editing.


Description

Return value is sanitize_term() and usage is for sanitizing the term for editing. Function is for contextual and simplicity.


Top ↑

Parameters

$id

(int|object)(Required)Term ID or object.

$taxonomy

(string)(Required)Taxonomy name.


Top ↑

Return

(string|int|null|WP_Error) Will return empty string if $term is not an object.


Top ↑

Source

File: wp-includes/taxonomy.php

function get_term_to_edit( $id, $taxonomy ) {
	$term = get_term( $id, $taxonomy );

	if ( is_wp_error( $term ) ) {
		return $term;
	}

	if ( ! is_object( $term ) ) {
		return '';
	}

	return sanitize_term( $term, $taxonomy, 'edit' );
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More