Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save loorlab/d9e00d1e59d6b4991fa70220978c432f to your computer and use it in GitHub Desktop.
Save loorlab/d9e00d1e59d6b4991fa70220978c432f to your computer and use it in GitHub Desktop.
Displays all taxonomies associated with the post's CPT and what terms are assigned to them. - WP CLI
wp eval '
$post_id = 53972; // ID
$post_type = get_post_type($post_id);
$taxonomies = get_object_taxonomies($post_type);
foreach ($taxonomies as $tax) {
$terms = get_the_terms($post_id, $tax);
echo "Taxonomía: $tax\n";
if (!empty($terms)) {
foreach ($terms as $term) {
echo "- {$term->name} (ID: {$term->term_id})\n";
}
} else {
echo "- No terms assigned";
}
echo "\n";
}
'
@loorlab
Copy link
Author

loorlab commented May 16, 2025

Taxonomía: post_tag

  • No terms assigned

Taxonomía: persons_categories

  • Actor (ID: 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment