In order to assign post_tags and custom_taxonomies from a post to a class, this is what I've been trying to do.

$terms = get_the_terms( $post->ID, array( 'post_tag', 'custom' );

if ( $terms ) {
    foreach ( $terms as $term ) {
        $termString .= $term->slug . ' ';

<div class="taxonomies here">content</div>

For some reason this doesn´t work, seems like get_the_terms does not support arrays for multiple taxonomies. How can this be worked around?


1 Answer 1


Anyway, I came across this from another question:

$terms = wp_get_object_terms( $post_id, get_object_taxonomies('post') );

and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.