0

Hello I am very new at customizing themes, my problem is that on my new post type "listing" single-lisiting.php file I need to change the taxonomy category to be display to 4 new taxonomies: status, location, type, bedroom. The code I have is:

<span class="itemCategory"><span class="icon-folder-close"></span> <?php echo __( 'Published in ', THEMENAME );?></span><?php the_category(", ");  ?>

Do not know how to change it, could someone help me.

2

If you're using a custom taxonomy, you can't use the_category() -- that's reserved for the default WordPress category taxonomy. Instead use the_terms():

<span class="itemCategory">
<span class="icon-folder-close"></span>
<?php echo __( 'Published in ', THEMENAME );?>
</span>
<?php the_terms( $post->ID, 'status', '', ", ", '' );

should output the status taxonomy for your post.

Reference

4
  • The problem is that the category is all ready used by the normal post type and have different terms, all ready create the new taxonomies to be able to sort by results, just need to add the right code into the new single-listing.php file that all ready have format. – Carlos Jun 17 '13 at 0:48
  • Yeah, I hit ENTER in the middle of typing my answer. It should be more complete now. You'll need to use the_terms() instead of the_category(). – Pat J Jun 17 '13 at 0:49
  • Just one more question, to show, the other 3 terms, how do I do that. location, type and bedroom – Carlos Jun 17 '13 at 1:01
  • Just change the 2nd argument to the_terms() to each of your taxonomy names: the_terms( $post->ID, 'location', '', ', ', '' ); and so forth. You'll need one call to the_terms() for each taxonomy name. – Pat J Jun 17 '13 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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