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.
-
AuthorPosts
-
February 8, 2013 at 9:08 pm #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
MatteyFebruary 9, 2013 at 1:13 pm #3365You might find this function useful:
eo_get_event_classes()
. As per the documentation it returns an array of HTML classes (including aseo-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 HarrisFebruary 9, 2013 at 4:37 pm #3376Thanks 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) {
?><?php echo ($now_description ? "$now_description" : "") ?>
<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
}
?>
MatteyFebruary 9, 2013 at 4:38 pm #3377Sorry, 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 } ?><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
}
?>MatteyFebruary 9, 2013 at 4:43 pm #3378Sorry again, the code option on the WYSIWYG isn’t letting me post correctly. Here is a screenshot of the code, my apologies:
MatteyFebruary 9, 2013 at 4:44 pm #3379February 9, 2013 at 4:48 pm #3380Let 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
MatteyFebruary 9, 2013 at 5:44 pm #3381The 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 HarrisFebruary 9, 2013 at 6:28 pm #3382Thank you! Totally got it to work. http://artsriot.com/
Cheers!
Mattey -
AuthorPosts