0
votes

with special thanks to every response on my last two questions, i have another important two: first : i need the next code to get meta terms from one specific taxonomy of my custom post type. i tried to replace: array('fields' => 'all') with array('fields' => 'proceeding') to get the meta terms only from the proceeding taxonomy, but it didn't work. any suggestions please? second : is there any way to let the code show the terms on different rows according to the different taxonomies when getting all terms from all taxonomies?

foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) {
    $object_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'all'));
    if ($object_terms) {
        echo ': (- ' . $taxonomy . ': ';// I modify the output a bit.
        $res = '';
        foreach ($object_terms as $term) {
            $res .= '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf(__("View all posts in %s"), $term->name) . '" ' . '>' . $term->name . '</a>, ';
        }
        echo rtrim($res,' ,').')';// I remove the last trailing comma and space and add a ')'
    }
}
1
What do you mean by it didn't work. Please provide the exact undesired behavior.Prerak Sola
hello, when replacing array('fields' => 'all') with array('fields' => 'proceeding'), nothing appears, no meta terms no taxonomies.nisr

1 Answers

0
votes

If you just want terms from the 'proceeding' taxonomy, you can use:

$object_terms = wp_get_object_terms($post->ID, 'proceeding');

Your question on putting things on different lines is not entirely clear. If you just add

'<br />'

at the end of the string, then the next one will be on a new line.