returning event-category to style a div with a particular event-category

WordPress Event Management, Calendars & Registration Forums General Question returning event-category to style a div with a particular event-category

This topic contains 8 replies, has 3 voices, and was last updated by  Mattey 11 years, 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #3350

    Hi.

    On the site I am working on, I am working with a slider/carousel that displays each event as a post (see here: http://artsriot.com/). I got it to display the events with an event category of “hot” with a specifically styled div. However in order to do this, it is calling 2 eo_get_events, one that just gets all events with an event-category of “hot” and the other that gets all events BESIDES ones in the”hot” event-category. It displays the HOT events first and then all others after. Because there is this split, HOT events will always show up first in the slider followed by the others. Since these events need to show in chronological order, it is important that all events show up ordered chronologically regardless of event-category. What I want to do is have all events show up in chronological order with the events with an event-category of “hot” styled as they are now. I can’t quite figure out how to do this. Thanks for any help!

    Matt

    Mattey
    #3365

    You might find this function useful: eo_get_event_classes(). As per the documentation it returns an array of HTML classes (including as eo-event-cat-hot, for events in the ‘hot’ category).

    Example usage would be:

    $classes = eo_get_event_classes( $post_id, $occurrence_id );
    printf( '<div class="event-slide %s">', implode(' ', $classes) );
    

    Then you can style ‘eo-event-cat-hot` etc as desired.

    Stephen Harris
    #3376

    Thanks for your help. So I was able to implement this and it is returning a class to the for each event. Check out the example here: http://artsriot.com/eventsslidertest/ However, the only category it is returning is: and none of the others like “eo-event-cat-“. Is there something I am missing? Thank you! Here is the code:


    20, ‘showrepeats’ => 0, ‘orderby’ => ‘eventstart’, ‘order’ => ‘ASC’,’showpastevents’=>false );
    $classes = eo_get_event_classes($args);
    $now_events = eo_get_events($args);
    if (count($now_events) > 0) {
    ?>

         &lt;?php echo ($now_description ? &quot;$now_description" : "") ?&gt;
    

    <div id="now_slider" class="es-carousel-wrapper">
    <div class="es-carousel">
    <ul class="event_slider">
    <?php
    foreach ($now_events as $post) {
    setup_postdata($post);
    ?>
    <?php printf( '<li class="%s">', implode(' ', $classes) ); ?><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail') ?>
    <div class="event_label"><p><?php the_title(); ?></p></div></a></li>
    <?
    }
    ?>
    <li><a href="/upcoming-events/"><img src="<?php echo get_template_directory_uri(); ?>/images/see-more-events-150.png" alt="more events" /></a></li>
    </ul>
    </div>
    </div>
    <br class="clear" />
    </div>
    <?php
    }
    ?>

    Mattey
    #3377

    Sorry, that didn’t post correctly, here is the code.

    <!-- BEGIN Now Slider -->
    <?php
    $args = array( 'numberposts' => 20, 'showrepeats' => 0, 'orderby' => 'eventstart', 'order' => 'ASC','showpastevents'=>false );
    $classes = eo_get_event_classes($args);
    $now_events = eo_get_events($args);
    if (count($now_events) > 0) {
    ?>
    <div class="slide_container">
    <? if ( $now_title ){ ?>
    <h1><?php echo $now_title ?> <?php echo ($now_description ? "<span class=\"slider_description\">$now_description</span>" : "") ?></h1>
    <?php } ?>

    &lt;div id="now_slider" class="es-carousel-wrapper"&gt;
        &lt;div class="es-carousel"&gt;
            &lt;ul class="event_slider"&gt;
            &lt;?php
                foreach ($now_events as $post) {
                    setup_postdata($post);
            ?&gt;
            &lt;?php printf( '&lt;li class="%s"&gt;', implode(' ', $classes) ); ?&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_post_thumbnail('thumbnail') ?&gt;
                &lt;div class="event_label"&gt;&lt;p&gt;&lt;?php the_title(); ?&gt;&lt;/p&gt;&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;?
                }
            ?&gt;
                &lt;li&gt;&lt;a href="/upcoming-events/"&gt;&lt;img src="&lt;?php echo get_template_directory_uri(); ?&gt;/images/see-more-events-150.png" alt="more events" /&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;br class="clear" /&gt;
    

    </div>
    <?php
    }
    ?>

    Mattey
    #3378

    Sorry again, the code option on the WYSIWYG isn’t letting me post correctly. Here is a screenshot of the code, my apologies:

    Mattey
    #3379
    Mattey
    #3380

    Let me do that again . . .

    Thanks for your help. So I was able to implement this and it is returning a class to the li for each event. Check out the example here: http://artsriot.com/eventsslidertest/ However, the only class it is returning is: “eo-event-past” and none of the others like “eo-event-cat-”. Is there something I am missing? Thank you! Here is the code:

    http://i84.photobucket.com/albums/k11/yzup/Screenshot2013-02-09at113948AM.png

    Mattey
    #3381

    The forum uses markdown (see the ‘?’ for help on posting code) – otherwise pastebin / gist is fine.

    eo_get_event_classes() doesn’t take query array – it takes two arguments, the event (post) ID and the occurrence ID.

    E.g.

    $events = eo_get_events( ... );
    
    foreach ( $events as $event ){
      $classes = eo_get_event_classes( $event->ID, $event->occurrence_id );
       printf( 'The classes for this event are: %s', implode(' ', $classes ) );
    }
    
    Stephen Harris
    #3382

    Thank you! Totally got it to work. http://artsriot.com/

    Cheers!

    Mattey
Viewing 9 posts - 1 through 9 (of 9 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.