Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi I'm trying to write a query which will pull the events out from the All in One Calendar Plugin. This is what I have so far:

<?php  query_posts('post_type=ai1ec_event');?>
<?php while ( have_posts() ) : the_post(); ?>
<?php echo '<h5><a href="'.get_permalink().'">'.get_the_title().'</a></h5>'; ?>
<?php endwhile; ?><!--  End the Loop -->

This works well to get the event titles and their respective content, but I need to get the event details out as well. eg. event dates, venue, location.

Thanks

share|improve this question
    
Can you try: <?php echo $location; ?> <?php echo $categories; ?> <?php echo $calendar_url; ?> etc. as found in event-single.php –  Pontus Abrahamsson Jun 8 '12 at 10:36
    
Thanks Pontus, I gave it a try but no joy. –  uknowit2 Jun 11 '12 at 9:48
add comment

2 Answers

Ok so hope this helps someone. Unless you want to query the database directly, the trick is to include the following:

$event = Ai1ec_Events_Helper::get_event($post->ID);

thereafter you can retrieve the variables, for example:

            <?php  query_posts('post_type=ai1ec_event');?>

            <?php while ( have_posts() ) : the_post(); ?>

            <?php $event = Ai1ec_Events_Helper::get_event($post->ID); ?>

            <?php echo '<h5><a href="'.get_permalink().'">'.get_the_title().'</a></h5>'; ?>

            <?php if( $event->multiday ) echo 'ai1ec-multiday' ?> <?php if( $event->allday ) echo 'ai1ec-allday' ?>

            <?php echo esc_html( $event->start_time ) ?>

            <?php echo $event->timespan_html ?>

            <?php echo $event->venue; ?>

            <?php if( $recurrence ): ?>
            <?php echo $recurrence ?>
            <?php endif ?>

            <?php if( $event->cost ): ?>
            <?php echo esc_html( $event->cost ) ?>
            <?php endif ?>

            <?php if( $contact ): ?>
            <?php echo $contact ?>
            <?php endif ?>

            <?php if( $categories ): ?>
            <?php echo $categories ?>
            <?php endif ?>

            <?php if( $tags ): ?>
                <?php echo $tags ?>
            <?php endif ?>

            <?php endwhile; ?><!--  End the Loop -->
share|improve this answer
    
Excellent, thank you for the answer. I will use this info to insert a related event into the single-post template of a custom post type of mine. –  Douglas.Sesar Jan 15 '13 at 18:08
add comment

date is in UNIX format. So I convert it:

$eventdate = $event->start; 
$mydate = date('M d, Y', $eventdate);
echo $mydate

Long time I'm can't get the post content and find a solution:

$text = $event->post->post_content;
echo $text;

perhaps useful to someone

share|improve this answer
    
I believe this may be a valid answer but I find it very hard to understand. Can you try to make it more clear? –  s_ha_dum May 21 '13 at 14:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.