wp_xmlrpc_server::get_term_custom_fields() WordPress Method

The wp_xmlrpc_server::get_term_custom_fields() method can be used to get the custom fields for a given term. This is useful for retrieving data that is specific to a given term, such as taxonomies or custom fields.

wp_xmlrpc_server::get_term_custom_fields( int $term_id ) #

Retrieve custom fields for a term.


Parameters

$term_id

(int)(Required)Term ID.


Top ↑

Return

(array) Array of custom fields, if they exist.


Top ↑

Source

File: wp-includes/class-wp-xmlrpc-server.php

	public function get_term_custom_fields( $term_id ) {
		$term_id = (int) $term_id;

		$custom_fields = array();

		foreach ( (array) has_term_meta( $term_id ) as $meta ) {

			if ( ! current_user_can( 'edit_term_meta', $term_id ) ) {
				continue;
			}

			$custom_fields[] = array(
				'id'    => $meta['meta_id'],
				'key'   => $meta['meta_key'],
				'value' => $meta['meta_value'],
			);
		}

		return $custom_fields;
	}


Top ↑

Changelog

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