Ant*_*rov 5 php wordpress custom-wordpress-pages
我正在使用Events Calendar Pro插件(https://theeventscalendar.com/product/wordpress-events-calendar-pro/),并且需要获取每个事件的所有类别。
我尝试过single_cat_title(),get_the_category()但是它们不是我所需要的。
实际上,single_cat_title()函数仅显示第一类,并get_the_category()返回空数组。
您可以使用以下代码来获取每个术语的详细信息。
$cats = get_the_terms( $post_id, 'tribe_events_cat' );
$term = get_term( $cats[1], $taxonomy ); // Getting the 2nd term item
$name = $term->name; //Getting names of terms
Run Code Online (Sandbox Code Playgroud)
更多详细信息请参见https://codex.wordpress.org/Function_Reference/get_term。
如果您还有其他问题,请告诉我。