Time.ly All In One Event Calendar Custom Query

The All in One Event Calendar by Time.ly is extremely flexible if you need to place several widgets and event shortcodes on your website.

Using the Plugin to generate your own custom query and feeds of your Event information is not very intuitive, and finding valid information a long process.

The below snippet shows you how to use WP_Query in tandem with Ai1ec_Event in order to parse the Plugins custom fields without the “ai1ec_” prefix.

<ul id="home_events">

	<?php $args = array(
		'post_type' => 'ai1ec_event',
		'posts_per_page' => 4,
		'tax_query' => array(array(
			'taxonomy' => 'events_categories',
			'field' => 'slug',
			'terms' => 'community-calendar'
		))
		
	); 
	
	global $ai1ec_registry;
	
	$events = new WP_Query($args);
	
	if($events->have_posts()) : while($events->have_posts()) : $events->the_post();
	/*
	echo '<pre>';
	print_r(get_post_meta(get_the_ID()));
	 echo '</pre>';
	*/
	
	
	$event = new Ai1ec_Event( $ai1ec_registry );
	$event->initialize_from_id( get_the_ID() );
	
	?>
	
		<li>
		
			<a href="<?php the_permalink(); ?>"><div class="home_event">
				<h3 class="event_title"><?php the_title(); ?></h3>
				<p><?php echo $event->get( 'start' )->format('g:i'); ?> - <?php echo $event->get( 'end' )->format('g:i A'); ?><br/>
				<strong>Location:</strong> <?php echo $event->get('venue'); ?></p>
			</div></a>
		</li>
	
	<?php endwhile; endif; wp_reset_query(); ?>

</ul><!-- #home_events -->

Usage:

Update this code and place it where you’d like Event post content to appear. Update the value in brackets to the name of the Time.ly Custom Field (without the ai1ec_ prefix).

<?php echo $event->get( 'start' )->format('g'); ?>

<?php echo $event->get('venue'); ?>

Custom Fields Available:

ai1ec_all_day_event
ai1ec_instant_event
ai1ec_start_time
ai1ec_end_time
ai1ec_venue
ai1ec_address
ai1ec_city
ai1ec_province
ai1ec_postal_code
ai1ec_country
ai1ec_google_map
ai1ec_cost
ai1ec_is_free
ai1ec_ticket_url
ai1ec_contact_name
ai1ec_contact_phone
ai1ec_contact_email
ai1ec_contact_url
ai1ec_input_coordinates
ai1ec_longitude
ai1ec_latitude
ai1ec_oauth_provider_twitter

 

5 thoughts on “Time.ly All In One Event Calendar Custom Query

  1. This was very helpful, we didn’t know you could query Time.ly events like this. I was trying to order the events by upcoming events. Could you help me with some direction?

    1. I could certainly try! It’s not recommended to query Time.ly events like this, but I have found that it is possible, even though it does get confusing. Do you have link or some code you send me to review? Email me at [email protected]

Leave a Reply to katherineCancel reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.