I have a taxonomy called ORGANIZER. All the terms of this taxonomy have a name and a description. I tried to get the description of each term but i don't know how to loop on them.
I suppose i mus begin with:
$terms = get_terms( array(
'taxonomy' => 'organizer',
'hide_empty' => false,
) );
but could you help me for the loop please ? thanks
I have a taxonomy called ORGANIZER. All the terms of this taxonomy have a name and a description. I tried to get the description of each term but i don't know how to loop on them.
I suppose i mus begin with:
$terms = get_terms( array(
'taxonomy' => 'organizer',
'hide_empty' => false,
) );
but could you help me for the loop please ? thanks
Share Improve this question edited Apr 15, 2020 at 9:00 Chetan Vaghela 2,4084 gold badges10 silver badges16 bronze badges asked Apr 14, 2020 at 15:10 PipooPipoo 491 silver badge5 bronze badges2 Answers
Reset to default 1get_terms()
returns an array of WP_Term
objects. To get the description, with the usual filters applied, you can pass this object to term_description()
:
$terms = get_terms( array(
'taxonomy' => 'organizer',
'hide_empty' => false,
) );
if ( ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
echo term_description( $term );
}
}
@jacob peattie
Sorry I have no rights to add comments so i add another answer, i don't know how do to better...
It seems that get_terms()
returns nothing but the organizer taxonomy exists and is not empty.