<?php
$post_id = 123; // Replace 123 with the ID of your post
$taxonomy = 'your_taxonomy'; // Replace 'your_taxonomy' with the name of your custom taxonomy or built-in taxonomy (e.g., 'category' or 'post_tag')
$terms = wp_get_post_terms($post_id, $taxonomy);
if (!empty($terms)) {
foreach ($terms as $term) {
// You can access term properties like term_id, name, slug, and more
$term_id = $term->term_id;
$term_name = $term->name;
$term_slug = $term->slug;
// Do something with the term data
echo "Term ID: $term_id<br>";
echo "Term Name: $term_name<br>";
echo "Term Slug: $term_slug<br>";
}
} else {
echo "No terms found for this post.";
}
?>