Home › Forums › Calendar Products › Community Events › Taxonomy + Categories, sub categories in Drop Down
- This topic has 1 reply, 2 voices, and was last updated 9 years, 9 months ago by Casey.
-
AuthorPosts
-
July 15, 2014 at 10:55 am #396262TranParticipant
Hello,
With the help of the forum I was able to make my categories in add event submission form show up in a drop down opposed to the check boxes… however, this drop down does not show any of my Categories only sub categories, which makes it confusing because nothing is organized, and there is duplicate subcategories within all categories…
for instance
Games
– cards
– board games
– othersports
– hockey
-golf
-otherother shows up in the list twice, how can I organize it so that in my drop down, it will show the main category and sub categories below that category and so on for each main category:
Here is the code i am using:
<?php
$event_cat_ids = array();
if ( $event ) {
$event_cats = wp_get_object_terms( $event->ID, TribeEvents::TAXONOMY );
foreach ( $event_cats as $event_cat ) {
$event_cat_ids[] = $event_cat->term_id;
}
} else {
$event_cats = array();
}
$args = array(
‘hide_empty’ => false,
‘orderby’ => ‘name’,
‘order’ => ‘ASC’,
‘exclude’ => $event_cat_ids,
);$cats = get_terms( TribeEvents::TAXONOMY, $args );
$cats = array_merge( $event_cats, $cats );
$cats = apply_filters( ‘tribe_community_events_event_categories’, $cats );echo ‘<select name=”tax_input[tribe_events_cat][]”>’;
echo ‘<option> Select a category </option>’;foreach ($cats as $cat)
echo ‘<option value=”‘.esc_attr($cat->term_id).'”>’.esc_html($cat->name).'</option>’;echo ‘</select>’;
?>July 17, 2014 at 8:22 am #429620CaseyParticipantTran,
Thanks for getting in touch! Unfortunately, due to our limited support resources we’re unable to help with specific changes to custom code such as this. Our support team does frequently provide code snippets to our users to point them in the right direction and get them started. However, any customizations that are needed beyond what we provide will be up to the user to perform or investigate on their own.Sorry that we’re not able to provide more help here, but hopefully this helps to clear up any confusion on what types of help we can and can’t provide. Thanks! 🙂
-Casey-
-
AuthorPosts
- The topic ‘Taxonomy + Categories, sub categories in Drop Down’ is closed to new replies.