Display event category in upcoming event list widget

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.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1160208

    Hi,
    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, Manuela

    #1160650
    Nico
    Member

    Hi 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:

    <?php

    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>',
    )
    );

    ?>

    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,
    Nico

    #1160807

    Hi 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,
    Manuela

    #1161526
    Nico
    Member

    Thanks 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,
    Nico

    #1161536

    Thank 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!!!

    #1162051
    Nico
    Member

    Hey! 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Display event category in upcoming event list widget’ is closed to new replies.