简体   繁体   English

Wordpress ACF-获取分类值

[英]Wordpress ACF - Get taxonomy values

I add new custom field to load my Books genres (taxonomy) in to my "writer" page (category). 我添加了新的自定义字段以将我的图书类型(分类法)加载到我的“作家”页面(类别)中。

look at my settings: http://awesomescreenshot.com/0df4qucud7 看一下我的设置: http : //awesomescreenshot.com/0df4qucud7

I need to show the checked genres on my writer page. 我需要在作者页面上显示选中的流派。 Of coure if theres no checked genres the code shows nothing (IF tag). 当然,如果没有检查的流派,代码什么也不显示(IF标签)。

How can I get the values? 如何获得这些值?

ACF Plugin: https://wordpress.org/plugins/advanced-custom-fields/ ACF插件: https//wordpress.org/plugins/advanced-custom-fields/

You are getting the term ID's of the selected genres. 您将获得所选类型的术语ID。 With the ID you can get a field like so get_field('field_name', 'genre-cat'); 使用ID,您可以得到一个类似get_field('field_name', 'genre-cat');的字段get_field('field_name', 'genre-cat'); In this situation the genre-cat can be replaced for the output of your field with the term IDs (you would have to do this for each term selected, so use the foreach statement). 在这种情况下,可以使用术语ID将genre-cat替换为您字段的输出(您必须为每个选择的术语执行此操作,因此请使用foreach语句)。

See full documentation from ACF on how to get values from a taxonomy term: http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ 请参阅ACF的完整文档,以了解如何从分类术语中获取值: http//www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM