Home › Forums › Calendar Products › Events Calendar PRO › Display event category in upcoming event list widget
- This topic has 6 replies, 3 voices, and was last updated 9 years, 7 months ago by
Manuela Hernandez Perez.
-
AuthorPosts
-
September 6, 2016 at 12:25 am #1160208
Manuela Hernandez Perez
ParticipantHi,
I need to display the event category in my sidebar using the upcoming event list widget. Unfortunately by default I can’t select it. How can I add it there? Thank you very much in advance for your help!
Best regards, ManuelaSeptember 6, 2016 at 2:35 pm #1160650Nico
MemberHi there Manuela,
Thanks for getting in touch! Glad to help you once again π
To achieve what you are looking for we an use a snippet or a template override:
Snippet: paste the code below in your theme’s (or child theme’s) functions.php file:
/* Tribe, add event categories to list widget */
add_action ( 'tribe_events_list_widget_after_the_meta', function ( ) {
echo tribe_get_event_categories(
get_the_id(), array(
'before' => '',
'sep' => ', ',
'after' => '',
'label' => null,
'label_before' => '<dt>',
'label_after' => '</dt>',
'wrap_before' => '<dd class="tribe-events-event-categories">',
'wrap_after' => '</dd>',
)
);
});
Please note that you can user other actions to change the position the categories display. Instead of hooking to tribe_events_list_widget_after_the_meta you can change that to any of the following: tribe_events_list_widget_before_the_meta, tribe_events_list_widget_after_the_event_title or tribe_events_list_widget_after_the_event_title . I guess the names are pretty self-explanatory.
Template override: as described in the themer’s guide creat a template override of: wp-content/plugins/events-calendar-pro/src/views/pro/widgets/modules/single-event.php. Once the copy of the file is in the correct path in your theme add the code below where you want the categories to display:
<?phpecho tribe_get_event_categories(
get_the_id(), array(
'before' => '',
'sep' => ', ',
'after' => '',
'label' => null,
'label_before' => '<dt>',
'label_after' => '</dt>',
'wrap_before' => '<dd class="tribe-events-event-categories">',
'wrap_after' => '</dd>',
)
);?>
This is basically the same code used in the snippet, but this solution can be better if the locations of the snippet don’t work for you.
Please let me know if this helps,
Best,
NicoSeptember 7, 2016 at 12:53 am #1160807Manuela Hernandez Perez
ParticipantHi Nick,
thank you for your help. I pasted the delivered code into my theme functions.php file and it works great. There’s just one small thing still: The “title” Veranstaltungskategorie should not be there above the category itself. As it doesn’t have a css class, I can’t remove it by editing the stylesheet. Do you have an idea how to do it? Here’s a screenshot that shows what I mean: http://prntscr.com/cf3qvr
Best regards,
ManuelaSeptember 8, 2016 at 8:45 am #1161526Nico
MemberThanks for following up Manuela!
Use this updated version of the snippet instead:
/* Tribe, add event categories to list widget */
add_action ( 'tribe_events_list_widget_after_the_meta', function ( ) {
echo tribe_get_event_categories(
get_the_id(), array(
'before' => '',
'sep' => ', ',
'after' => '',
'label' => null,
'label_before' => '<dt style="display:none;">',
'label_after' => '</dt>',
'wrap_before' => '<dd class="tribe-events-event-categories">',
'wrap_after' => '</dd>',
)
);
});
I’ve added some inline style to hide the label. Also tried to set label, label_before and label_after to ” but the : are still there, anyway the inline styles makes it work π
Please let me know if this is was you were looking for,
Best,
NicoSeptember 8, 2016 at 9:24 am #1161536Manuela Hernandez Perez
ParticipantThank you, Nico. It works! I really love your support, you always find a great solution π
Could you please have a look at the other issue that is there: https://theeventscalendar.com/support/forums/topic/events-date-format/
Muchas gracias!!!September 9, 2016 at 8:30 am #1162051Nico
MemberHey! Thanks for the compliment, always glad to help out π
Regarding the other thread, it looks like Cliff is actively helping there and found a solution for the issue. I’ll keep an eye on the thread anyway!
Iβll go ahead and close out this thread, but if you need help with anything else please donβt hesitate to create a new one and we will be happy to assist you.
Have a great weekend,
Nico -
AuthorPosts
- The topic ‘Display event category in upcoming event list widget’ is closed to new replies.
