get term name by term id in wordpress
To get the term name by term ID in WordPress, you can use the get_term_by() function. Here's an example:
$term_id = 123; // Replace with your term ID
$term = get_term_by('id', $term_id, 'taxonomy'); // Replace 'taxonomy' with the actual taxonomy of your term
if ($term) {
$term_name = $term->name;
echo $term_name;
} else {
echo 'Term not found';
}
Make sure to replace 'taxonomy' with the actual taxonomy of your term (e.g., 'category', 'post_tag').
原文地址: https://www.cveoy.top/t/topic/iCyD 著作权归作者所有。请勿转载和采集!