2

I am using custom post types in a theme optimized for web radios (custom theme). I added a custom post type called "Radio Shows" and registered two custom taxonomies: one hierarchical (like default "categories", I named it GENRE) and the other is not (like "tags", I named it INSTRUMENTS).

I've managed to get that custom post type's posts displayed in index.php with the rest of the default post type's posts and also created a page template that displays only the custom post type's posts (Radio Shows).
It works fine, I can see them being displayed normally, in correct order etc. What's not being displayed in both pages (index & template page dedicated to custom post type) is the custom taxonomies.

In default posts, inside the loop are being displayed:

  1. CATEGORIES
  2. TITLE
  3. THUMBNAILS
  4. CONTENT
  5. TAGS.

What I want to achieve is to get GENRE & INSTRUMENT custom taxonomies displayed in the place that CATEGORIES & TAGS do in default post types.

Normally I should tell you what I have tried so far... well, I tried at least 20 ways I found on several tutorial websites so it's difficult to list them. None of them worked for me.

2
  • What is the exact name you used to register the post type and the taxonomies?
    – fuxia
    Commented Apr 20, 2013 at 21:16
  • radio_show is the name of the post type and genre/instruments for the taxonomies
    – ArgGeo
    Commented Apr 20, 2013 at 21:27

1 Answer 1

1

Use the_terms():

the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' )

So in your loop:

if ( 'radio-shows' === get_post_type() )
{
    the_terms( get_the_ID(), 'genre' );
    the_terms( get_the_ID(), 'instruments' );
}
else
{
    the_category();
    the_tags();
}
1
  • Toscho thanks for the answer. Unfortunately only the ELSE works as it should in default post type posts. I get nothing in custom post type posts. EDIT: WORKS LIKE A CHARM! GOD BLESS YOU TOSCHO! THANKS A LOT!!!
    – ArgGeo
    Commented Apr 20, 2013 at 21:15

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.