Uses
Uses | Description |
---|---|
wp-includes/taxonomy.php: has_term_meta() | Get all meta data, including meta IDs, for the given term ID. |
wp-includes/capabilities.php: current_user_can() | Returns whether the current user has the specified capability. |
Retrieve custom fields for a term.
(int) (Required) Term ID.
(array) Array of custom fields, if they exist.
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; }
Version | Description |
---|---|
4.9.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/get_term_custom_fields