• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / get_term_field() – Get sanitized Term field.

You appear to be a bot. Output may be restricted

Description

Get sanitized Term field.

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

Usage

$string|int|null|WP_Error = get_term_field( $field, $term, $taxonomy, $context );

Parameters

$field
( string ) required – Term field to fetch.
$term
( int|WP_Term ) required – Term ID or object.
$taxonomy
( string ) optional – Optional. Taxonomy Name. Default empty.
$context
( string ) optional default: display – Optional. How to sanitize term fields. Look at sanitize_term_field() for available options. Default 'display'.

Returns

string|int|null|WP_Error Will return an empty string if $term is not an object or if $field is not set in $term.

Source

File name: wordpress/wp-includes/taxonomy.php
Lines:

1 to 16 of 16
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 );
}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: get_term_field
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/taxonomy.php
File ref: wp-includes/taxonomy.php
Deprecated?: No
API Letters: F,G,T

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites