-
-
Save revaboogy/9117088 to your computer and use it in GitHub Desktop.
Category list with child categories for Wordpress Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$terms = get_terms("tribe_events_cat", array( | |
'parent' => 0, | |
)); | |
//print_r ($terms); | |
// $terms = ($terms [parent] => 0 ); | |
$count = count($terms); | |
if ( $count > 0 ){ | |
echo '<ul class="events-cat-menu">'; | |
?> | |
<?php foreach ( $terms as $term ): ?> | |
<li class="cat_<?php esc_attr_e($term->slug); ?>"><a href="<?php get_term_link($term->slug, 'tribe_events_cat'); ?>"><?php esc_html_e($term->name); ?></a> | |
<ul> | |
<?php | |
// get children | |
$kids = get_terms('tribe_events_cat', array( | |
'parent'=>$term->term_id, | |
)); | |
foreach ( $kids as $kid) { | |
echo '<li class="cat_'. $kid->slug .'"><a href="'. get_term_link($kid->slug, 'tribe_events_cat') .'">' . $kid->name . '</a></li>'; | |
} | |
?> | |
</ul> | |
</li> | |
<?php endforeach; ?> | |
<? | |
echo '</ul>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment