Home › Forums › Calendar Products › Events Calendar PRO › Show subcategories in category view
- This topic has 5 replies, 4 voices, and was last updated 7 years, 7 months ago by Marlene Hassel.
-
AuthorPosts
-
August 17, 2016 at 2:35 am #1152477Marlene HasselParticipant
Is there a way to do that?
August 17, 2016 at 1:35 pm #1152805NicoMemberHi Marlene,
Thanks for getting in touch! Nice mock up š
What you are looking for is possible with a bit of custom code, I can help you get started with this:
/* Tribe subcategory nav for photo view */
function tribe_add_subcategories ( ) {global $wp_query;
// bail if the function is not defined or we are not in photo view or if no event category is set
if ( !function_exists('tribe_is_photo') || !tribe_is_photo() || !isset( $wp_query->query_vars[ Tribe__Events__Main::TAXONOMY ] ) ) return false;$termparent = get_queried_object();
$termchildren = get_term_children( $termparent->term_id, Tribe__Events__Main::TAXONOMY );// bail if no children
if ( empty($termchildren) ) return false;// display children
echo '- ';
- ' . $term->name . '
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, Tribe__Events__Main::TAXONOMY );
echo '';
}
echo '';
}
add_action( 'tribe_events_after_the_title', 'tribe_add_subcategories' );
Paste the code above in your theme’s (or child theme’s) functions.php file and give it a try š
Best,
NicoAugust 18, 2016 at 2:56 am #1153037Marlene HasselParticipantThanks!
2 more things:
- I’d like to show the subcategory events in their respective subcategories only, and not in the parent category.
- Would it be possible to give each subcategory a featured image so that they can be displayed in the same way as the events?
August 18, 2016 at 7:54 pm #1153481NicoMemberYou are welcome Marlene!
Iād like to show the subcategory events in their respective subcategories only, and not in the parent category.
Sure, try this updated version of the snippet instead:
/* Tribe subcategory nav for photo view */
function tribe_add_subcategories ( ) {global $wp_query;
// bail if the function is not defined or we are not in photo view or if no event category is set
if ( !function_exists('tribe_is_photo') || !tribe_is_photo() || !isset( $wp_query->query_vars[ Tribe__Events__Main::TAXONOMY ] ) ) return false;$termparent = get_queried_object();
$termchildren = get_term_children( $termparent->term_id, Tribe__Events__Main::TAXONOMY );// bail if no children
if ( empty($termchildren) ) return false;// display children
echo '- ';
- ' . $term->name . '
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, Tribe__Events__Main::TAXONOMY );
echo '';
}
echo '';
}
add_action( 'tribe_events_after_the_title', 'tribe_add_subcategories' );
Would it be possible to give each subcategory a featured image so that they can be displayed in the same way as the events?
Yes, this functionality can be added with a plugin: Category and Taxonomy Image, Easy Taxonomy Images, Taxonomy Images, etc.
Please let me know if there’s anything else I can do for you,
Best,
NicoSeptember 9, 2016 at 9:35 am #1162131Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Show subcategories in category view’ is closed to new replies.