Display a post's category within the wordpress loop?

前端 未结 4 1915
我在风中等你
我在风中等你 2021-02-11 07:07

Okay, so I have a Wordpress template that I created that only displays posts that have the \"workout\" category associated with it. Within the loop that displays those, I want t

4条回答
  •  北海茫月
    2021-02-11 08:03

    Get the post category if you have a custom post_type

    ID, 'taxonomy' );
    // now you can view your category in array:
    // using var_dump( $categories );
    // or you can take all with foreach:
    foreach( $categories as $category ) {
        echo $category->term_id . ', ' . $category->slug . ', ' . $category->name . '
    '; } ?>

    click here for detail

提交回复
热议问题