Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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");
}
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Works like a charm! Stephen you rock my world. –  Zade Jul 17 '12 at 20:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.