Last active
August 16, 2024 19:46
-
-
Save lukaspawlik/045dbd5b517a9eb1cf95 to your computer and use it in GitHub Desktop.
AI1EC usage sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ai1ec2_display_events_func( $atts ) { | |
global $ai1ec_registry; | |
$content = '<div id="content2"><img src="/wp-content/themes/scio/images/events-header.png" alt="" />'; | |
$time = $ai1ec_registry->get( 'date.system' ); | |
// Get localized time | |
$timestamp = $time->current_time(); | |
// Set $limit to the specified categories/tags | |
$limit = array( | |
// | |
// this is demo data - please use your own filters | |
// | |
'tag_ids' => array ( 29 ) | |
); | |
$events_per_page = 2; | |
$paged = 0; | |
$event_results = $ai1ec_registry->get( 'model.search' ) | |
->get_events_relative_to( | |
$timestamp, | |
$events_per_page, | |
$paged, | |
$limit | |
); | |
$dates = $ai1ec_registry->get( | |
'view.calendar.view.agenda', | |
$ai1ec_registry->get( 'http.request.parser' ) | |
)->get_agenda_like_date_array( $event_results['events'] ); | |
foreach ( $dates as $date ) { | |
foreach ( $date['events']['allday'] as $instance ) { | |
$post_title = $instance->get( 'post' )->post_title; | |
$post_name = $instance->get( 'post' )->post_name; | |
$post_content = $instance->get( 'post' )->post_content; | |
$instance_id = $instance->get( 'instance_id' ); | |
$content .= '<div class="hp-event"> | |
<a href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">' | |
.$post_title.'</a><br />' | |
.$post_content. | |
'<a class="read-more-link" href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">read more</a> | |
</div>'; | |
} | |
foreach ( $date['events']['notallday'] as $instance ) { | |
$post_title = $instance->get( 'post' )->post_title; | |
$post_name = $instance->get( 'post' )->post_name; | |
$post_content = $instance->get( 'post' )->post_content; | |
$instance_id = $instance->get( 'instance_id' ); | |
$content .= '<div class="hp-event"> | |
<a href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">' | |
.$post_title.'</a><br />' | |
.$post_content. | |
'<a class="read-more-link" href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">read more</a> | |
</div>'; | |
} | |
} | |
$content .= '</div>'; | |
return $content; | |
} | |
add_shortcode( 'display_events2', 'ai1ec2_display_events_func' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@nelero - Can you elaborate on your comment? I'm not quite following-