I've tried looking for a article that can help but not getting far, I have a custom post;

  $args = array( 
  'post_type' => 'swatches', 
  'posts_per_page' => 9999, 
  'order' => 'ASC',                               
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();

And I want to output the title (easy) and the custom post category it relates to e.g. luxury, standard etc. I've added;

'taxonomies' => array('swatches-category','swatches-tags')

In my functions and can get it to display all of the categories but not the one it relates too.

I'm trying;

<?php $terms = get_terms('swatches-category'); echo $term->name; ?>

But no success...

Can anyone help please?

Thanks in advance

1 Answer 1

<?php $terms = get_the_terms( $post->ID , 'swatches-category' ); foreach ( $terms as $term ) {  echo $term->name; } ?>

That solved it! :-)

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.