I use the Events Calendar Pro plugin ( https://theeventscalendar.com/product/wordpress-events-calendar-pro/ ) and I need to get all categories for each event.
I tried single_cat_title()and get_the_category(), but I do not need them.
single_cat_title()
get_the_category()
In fact, the function single_cat_title()shows only the first category, but get_the_category()returns an empty array.
You can use the following code to get detailed information about each term.
$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
https://codex.wordpress.org/Function_Reference/get_term.
, .
single_cat_title() get_the_category(), .
get_the_category() , . , Calendar pro, , get_the_terms().
get_the_terms() post_id /.
, , : -
$event_cats = get_the_terms( $post_id, 'tribe_events_cat' )
, ...
Source: https://habr.com/ru/post/1675110/More articles:Nginx disables static file loading early - pythonIn Python 3.5, when dividing an even number, why division and gender division give different answers - pythonHow to register UDF for use in SQL and DataFrame? - scalaHow not to animate a list view in XAML? - c #com.android.ddmlib.InstallException: Failed to install everything - androidHow to replace a global function while executing unit test with a joke - unit-testingЕсть ли необходимость использовать изображения @1x, если приложение создает устройства iPhone 4+? - iosFTP for Google Storage - google-app-engineHow can you determine if a variable is a two-dimensional array, an array of pointers, or double char pointers? - cHiding the middle view first in terms of the coordinator - androidAll Articles