Created
May 16, 2025 23:12
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taxonomía: post_tag
Taxonomía: persons_categories