最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Display the description of taxonomy terms

programmeradmin3浏览0评论

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 badges
Add a comment  | 

2 Answers 2

Reset to default 1

get_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.

发布评论

评论列表(0)

  1. 暂无评论