0

I've been having issues with this all morning and need some help.

So I made a custom post type called Equipment, then made a custom taxonomy called Equipment Types. On single-equipment.php I can get it to display the title, content and custom fields associated with the post, but I can't get the Equipment Type selected to display.

I've looked through the get_terms codex, and I can get it to list all the terms for Equipment Type that have posts associated with them, but not the one that was selected for the specific post.

So if I have made a new Equipment post titled "Molo H8500" and the Equipment Type Tax Term is "Speaker", I'm looking to have the single-equipment.php just display Speaker. So for example the page would display:

Title : Molo H8500

Content : The MOLO H8500 speaker is a...

Custom fields : Height: 48" and Widght: 36"

Custom Taxonomy : Equipment Type: Speaker (can't get to display)

Any help would be appreciated, thanks!

1 Answer 1

0

The function you want is get_the_terms.

$terms = get_the_terms( get_the_ID(), 'equipment_type' );
if ( $terms && ! is_wp_error( $terms ) ){
    foreach ( $terms as $term ) {
        echo $term->name;
    }
}
1
  • gah this is exactly what I needed, thank you so much Milo!
    – Joe
    Dec 4, 2015 at 15:11

Your Answer

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

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