wp_xmlrpc_server::get_term_custom_fields( int $term_id ): array

In this article

Retrieves custom fields for a term.

Parameters

$term_idintrequired
Term ID.

Return

array Array of custom fields, if they exist.

Source

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;
}

Changelog

VersionDescription
4.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.