Uma área de pesquisa sobre o WordPress para devs e autores do tema



get_term_field ›

Desde2.3.0
Obsoleton/a
get_term_field ( $field, $term, $taxonomy = '', $context = 'display' )
Parâmetros: (4)
  • (string) $field Term field to fetch.
    Required: Yes
  • (int|WP_Term) $term Term ID or object.
    Required: Yes
  • (string) $taxonomy Optional. Taxonomy Name. Default empty.
    Required: No
    Padrão: (empty)
  • (string) $context Optional, default is display. Look at sanitize_term_field() for available options.
    Required: No
    Padrão: 'display'
Ver:
Retorna:
  • (string|int|null|WP_Error) Will return an empty string if $term is not an object or if $field is not set in $term.
Definido em:
Codex:
Log de mudanças:
  • 4.4.0 The ` $taxonomy` parameter was made optional. ` $term` can also now accept a WP_Term object.

Get sanitized Term field.

The function is for contextual reasons and for simplicity of usage.



Fonte

function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
	$term = get_term( $term, $taxonomy );
	if ( is_wp_error($term) )
		return $term;

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

	if ( !isset($term->$field) )
		return '';

	return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
}