Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress-如何从术语ID获取术语名称?_Php_Wordpress_Taxonomy Terms - Fatal编程技术网

Php Wordpress-如何从术语ID获取术语名称?

Php Wordpress-如何从术语ID获取术语名称?,php,wordpress,taxonomy-terms,Php,Wordpress,Taxonomy Terms,我正在尝试从分类法中检索$title的术语名称。我遇到过很多Codex函数,比如get\u post\u meta(),get\u theu terms()等等,它们似乎只从post\u id中获取术语名称,这不是我要找的 如何从term\u id获取术语名称?请尝试以下操作: <?php $term = get_term_by( $field, $value, $taxonomy); ?> 我希望,这可能对您有所帮助。您可以从term\u id中获得术语名称,如下所示: $ter

我正在尝试从分类法中检索
$title
的术语名称。我遇到过很多Codex函数,比如
get\u post\u meta()
get\u theu terms()
等等,它们似乎只从
post\u id
中获取术语名称,这不是我要找的

如何从
term\u id
获取术语名称?

请尝试以下操作:

<?php $term = get_term_by( $field, $value, $taxonomy); ?>

我希望,这可能对您有所帮助。

您可以从term\u id中获得术语名称,如下所示:

$term_name = get_term( $term_id )->name;
说明:
get\u term()
返回term对象,
name
是此对象的属性之一

有关法典的更多详细信息:

我想你是在用Wordpress吧?请将此标签添加到您的问题中,至少让我们知道您在说什么。检查此链接:不直接调用
get\u term
的任何原因可能重复?@yivi我没有说get\u term不正确,您在评论中已经告诉我们使用get\u term,这就是为什么我给出了get\u term以外的另一个选项,如果我也告诉他使用get_term(),那么你的评论有什么用呢。问过这个问题的人应该有各种各样的答案来获得额外的知识。所有提供答案的用户只告诉一个答案是没有用的。不用担心。只是想知道这背后是否有更有趣的原因。@yivi好的,兄弟,没问题。
$term_name = get_term( $term_id )->name;