johny
johny

Reputation: 159

Get the terms of a custom taxonomy without explicit taxonomy IDs in Wordpress

I used the following code to try it but it doesnt work. I need all terms of the taxnonmy which are saved for this explicit post. But I only get "array".

get_the_terms( $post->ID, 'regisseur', 'Regisseur: <span class="flight">

Additional I want to except the ID 43 and 76 – this terms shouldnt be shown in the list.

Why it doesnt work?

Upvotes: 0

Views: 566

Answers (1)

Orbital
Orbital

Reputation: 956

If you need to get all the terms in a post, you should use wp_get_post_terms() instead of get_the_terms()

Try this (updated)

<?php

$terms = wp_get_post_terms($post->ID, 'regisseur');
if ($terms)
{
    $output = '';
    foreach ($terms as $term) {
    //Here we exclude terms
    if ($term->term_id == 43) continue;
    if ($term->term_id == 76) continue;

            $output .= '<span><a href="' . get_term_link($term->slug, 'regisseur') . '">' . $term->name . '</a></span>';    

    }
};
?>

Upvotes: 1

Related Questions