I’m trying to retrieve term names from taxonomies for
$title. I have come across a lot Codex functions like
get_the_terms() etc, which seem to only get term name from
post_id, which is not what I’m looking for.
How do I get term names from
You may get the term name from term_id like this:
$term_name = get_term( $term_id )->name;
get_term() returns the term object and
name is one of propeties of this object.
More details on codex:
Please try this:
<?php $term = get_term_by( $field, $value, $taxonomy); ?>
- $field => Just write
- $value => Place your
- $taxonomy => write your custom taxonomy
For ex: My custom
taxonomy slug is ‘
services‘ & ‘
5, so here is the code for retrieving
<?php $term = get_term_by( 'id', 5, 'services' ); echo $term->name; ?>
I hope, this may be helpful to you.