I’m trying to populate a form value field with a taxonomy term associated with the current post,
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 );
and this for the form field:
<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 ..?
Many thanks
Use
wp_get_post_terms
to retrieve your post terms. syntax here:http://codex.wordpress.org/Function_Reference/wp_get_post_terms
You can use
get_the_terms()
.The difference between
get_the_terms()
andwp_get_post_terms()
is thatget_the_terms()
‘s results are cached.