在 wordpress 中获取当前帖子的分类术语 [英] Getting a taxonomy term for the current post in wordpress
本文介绍了在 wordpress 中获取当前帖子的分类术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用与当前帖子关联的分类术语填充表单值字段,
I'm trying to populate a form value field with a taxonomy term associated with the current post,
我一定尝试了 20 件事,但找不到正确的解决方案.?
I must have tried 20 things but cant find the right solution .?
我有元字段,但这很简单,我刚刚使用了这个:
I have meta fields but that's easy I have just used this:
$ref = get_post_meta( $post->ID, 'job_ref', true );
这对于表单字段:
<input type="text" class="text" name="job_ref" id="job_ref" value="
<?php echo $ref; ?>" />
所以我正在为分类术语寻找类似的解决方案......?
So I'm looking for a similar solution for a taxonomy term ..?
非常感谢
推荐答案
使用 wp_get_post_terms
来检索您的帖子条款.这里的语法:
Use wp_get_post_terms
to retrieve your post terms. syntax here:
http://codex.wordpress.org/Function_Reference/wp_get_post_terms
这篇关于在 wordpress 中获取当前帖子的分类术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文