找到你要的答案

Q:WordPress | How to get custom field taxonomy term value

Q:WordPress |如何自定义字段分类项值

I use 2 plugins:

  1. Types - to create taxonomy term

  2. Advanced Custom Fields - to create custom fields

I have custom field called "age" on taxonomy term called "artist"

Screenshot: http://www.awesomescreenshot.com/image/172306/087480247421ba210f77ffabf7aa046f

For example I have "artist" term called "Angelina Jolie", and his age value is "40"

I want to to get "age" value on single post who use the specific artist term, in my example I want to get 40 ("age" value) on every single post who use the "Angelina Jolie" term.

How can I do that?

我使用2插件:

  1. 类型-创建分类术语

  2. 高级自定义字段-创建自定义字段

我有一个自定义的字段称为“年龄”分类术语称为“艺术家”

http://www.awesomescreenshot.com/image/172306/087480247421ba210f77ffabf7aa046f截图:

比如我有“艺术家”的术语叫“安吉莉娜·朱莉”,与他的年龄值为“40”

我想把“年龄”的价值单后谁使用特定的艺术家而言,在我的例子中我想得到40(“年龄”值)在每一个帖子谁使用“安吉莉娜·朱莉”一词。

我该怎么做?

answer1: 回答1:

As suggested by AlliterativeAlice, use get_field() but pass in the field name, in your case:

$value = get_field("age");

The content of the $value variable should now be 40.

建议由alliterativealice,使用get_field()但在字段名通,你的情况:

$value = get_field("age");

值变量的内容应该是40。

php  wordpress