^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_term_field()用法示例

get_term_field( string $field,  int|WP_Term $term,  string $taxonomy = '',  string $context = 'display' )

Get sanitized Term field.


描述

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

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


参数

$field

(string)
(Required)
Term field to fetch.

$term

(int|WP_Term)
(Required)
Term ID or object.

$taxonomy

(string)
(Optional)
Taxonomy Name.

Default value: ''

$context

(string)
(Optional)
default is display. Look at sanitize_term_field() for available options.

Default value: 'display'


返回值

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


源代码

File: wp-includes/taxonomy.php

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

更新日志

Version 描述
4.4.0 The $taxonomy parameter was made optional. $term can also now accept a WP_Term object.
2.3.0 Introduced.

相关函数

Uses

  • wp-includes/taxonomy.php:
    sanitize_term_field()
  • wp-includes/taxonomy.php:
    get_term()
  • wp-includes/load.php:
    is_wp_error()

Used By

  • wp-includes/customize/class-wp-customize-nav-menu-item-setting.php:
    WP_Customize_Nav_Menu_Item_Setting::get_original_title()
  • wp-admin/includes/class-walker-nav-menu-edit.php:
    Walker_Nav_Menu_Edit::start_el()
  • wp-includes/category-template.php:
    term_ 描述()
  • wp-includes/nav-menu.php:
    wp_setup_nav_menu_item()
  • wp-includes/nav-menu.php:
    wp_update_nav_menu_item()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈