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!

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;
    }
}
  • gah this is exactly what I needed, thank you so much Milo! – Joe Dec 4 '15 at 15:11

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.