If I understand correctly,
wp_get_post_tags
returns the “post_tags”
taxonomy terms.
Yes, except that the taxonomy is post_tag
and not post_tags
.
How can I access “attachment_keywords” taxonomy terms?
wp_get_post_tags()
uses wp_get_post_terms()
, so you would do the same for custom taxonomies.
For example if the taxonomy (name/slug) is attachment_keywords
, then:
$tags = wp_get_post_terms( $post->ID, 'attachment_keywords' );
And that should work, but as suggested in the documentation for wp_get_object_terms()
that’s used by wp_get_post_terms()
, you might want to use get_the_terms()
instead which caches the results and thus can help improve performance, specifically when looping over posts results.