Event Organiser
[resolved] Event listing by date and category styling (4 posts)

  1. sounddog
    Posted 3 years ago #

    Hi Stephen,

    First of all, thanks for the great plug-in. It has all the functionality I need, although I'm struggling to figure out how to output what I want. Basically I'm trying to create a page with functionality similar to the agenda widget where events are grouped by date. Depending upon what category the event is in I would like to style it differently. An example would be something like below but with colour etc.

    Euro Cup Semi Final TBD, 11:45 am
    1/2 Price Wings, Local & Organic
    $14 Pitchers of Lager
    Open Mic 9 pm

    Euro Cup Semi Final TBD, 11:45 am
    Fresh Cask Ale Keg Tapping at 6 pm

    Although I've been a Java developer for years I'm reasonably new to PHP and WordPress. I've been trying to work through agenda widget to understand how the grouping works but there doesn't seem to be anything there. I then looked at the archive template, but again I can't find anything when seems to do what I am seeing happen in the widget.

    Could you point me in the right direction for what I need to do? Can I achieve this with the templates and short codes or do I need to create a new page template and use the functions you provide to obtain the events, group them and display them?

    Thanks again,


  2. sounddog
    Posted 3 years ago #

    Got it sorted. Amended the archive template so that it displayed the date only on event date change (after all it's already sorted by date), then got the category from the term list and stripped the tags from it.

    //Events have their own 'event-category' taxonomy. Get list of categories this event is in.
    $category = strip_tags( get_the_term_list( $wp_query->post->ID, 'event-category', '', ', ', '' ) );

    I can now append the category to the css class to style the line appropriately

  3. Stephen Harris
    Plugin Author

    Posted 3 years ago #

    Spot on with how to handle the grouping of events - this is how the agenda widget does it too. I've explained in more detail how to do this on one of the forum posts here.

    For the category classes, you could also use $terms = get_the_terms(get_the_ID(),'event-category') inside the loop to retrieve the post's terms. Then extract an array of term-slugs with wp_list_pluck, and finally implode the array of slugs into a space delimited string. This method is probably preferable:

    $terms = get_the_terms(get_the_ID(),'event-category')
    $slugs = wp_list_pluck($terms,'slug');
    $class = implode(' ',$slugs);

    (you might need to perform some checks in case $terms is empty.

  4. sounddog
    Posted 3 years ago #

    Thanks Stephen. All your feedback to myself and others on the forum have been a great help.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Event Organiser
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic