简体   繁体   中英

Get every category in custom post type [Wordpress] [Events Manager]

I am having trouble to get all categories of specifically the plugin Events Manager. What I am trying to achieve is an select field with every category available in Events Manager in a template file. I tried using wordpress functions like get_terms() but couldn't figure out what to use as args.

I am getting my results like this:

$events = EM_Events::get(array('limit'=>0));
foreach( $events as $EM_Event ){
    ...
}

I appreciate any help

Events manager registers event-categories taxonomy (for categories), and event-tags taxonomy (for tags).

So to get all the terms for a certain category, you can use, as you noted,

$event_terms = get_terms( 'event-categories', array(
    'hide_empty' => false,
) );

This should return an array of all the terms for that taxonomy.

Read more here: https://developer.wordpress.org/reference/functions/get_terms/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM