How to use get_categories() with Event Organiser plugin

I want to display my categories in tabs. All is good, except my “Upcoming Events”, created with Event Organiser (awesome plugin at http://wordpress.org/extend/plugins/event-organiser/), are not being treated like a normal category, so they don’t appear. In essence, get_categories() is not returning the events category. How can I fix this display?

$args = array('type'=> 'post', 'order' => 'ASC', 'hide_empty' => 1 );
$categories = get_categories( $args );
foreach($categories as $category) {
    echo '<li><a href="#tabs-content-'.strtolower($category->term_id).'" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></li>';
    array_push($cat_list,"$category->term_id");
}

Related posts

Leave a Reply

1 comment

  1. Event categories are terms in a custom taxonomy, ‘event-category’, so you should use get_terms instead:

    //Args for which terms to retrieve
    $args = array('type'=> 'post', 'order' => 'ASC', 'hide_empty' => 1 );
    
    //Array of taxonomies from which to collect the terms
    $taxonomies = array('event-category');
    
    //Get the terms
    $terms = get_terms( $taxonomies, $args);
    
    //loop through the terms and display
    foreach($terms as $term) {
        echo '<li><a href="#tabs-content-'.strtolower($term->term_id).'" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a></li>';
        array_push($cat_list,"$term->term_id");
    }
    

    If you want to get terms for both the ‘category’ and ‘event-category’ taxonomy then you can add ‘category’ to the $taxonomies array.