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()
and wp_get_post_terms()
is that get_the_terms()
's results are cached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With