What function will display custom taxonomies associated with a post as text?
I'm currently using get_the_term_list which works great for a singular page but not so much when using a taxonomy in the archive-postype.php permalink title tag.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
wp_get_object_terms() returns the terms associated with an object (eg a post or a page or custom post) as text (normally in an array).
$productcategories = wp_get_object_terms($post->ID, 'productcategories');
I need the same and tried Zack solution that works great. For instance, if you need onlye the term to put in css id or class. Only one anotation about the solution, the function is bad called, properly is "get_the_term_list".
I show my example:
$terms = get_the_term_list( $post->ID, 'your_taxonomy_name' ); $terms = strip_tags( $terms );