wp_get_split_term() WordPress Function

The wp_get_split_term() function splits a term by its namespace and returns an array of the term_id and term_taxonomy_id. This function is useful for getting a term's parent.

wp_get_split_term( int $old_term_id, string $taxonomy ) #

Gets the new term ID corresponding to a previously split term.


Parameters

$old_term_id

(int)(Required)Term ID. This is the old, pre-split term ID.

$taxonomy

(string)(Required)Taxonomy that the term belongs to.


Top ↑

Return

(int|false) If a previously split term is found corresponding to the old term_id and taxonomy, the new term_id will be returned. If no previously split term is found matching the parameters, returns false.


Top ↑

Source

File: wp-includes/taxonomy.php

function wp_get_split_term( $old_term_id, $taxonomy ) {
	$split_terms = wp_get_split_terms( $old_term_id );

	$term_id = false;
	if ( isset( $split_terms[ $taxonomy ] ) ) {
		$term_id = (int) $split_terms[ $taxonomy ];
	}

	return $term_id;
}


Top ↑

Changelog

Changelog
VersionDescription
4.2.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