Answer the question
In order to leave comments, you need to log in
All in one event calendar plugin for WordPress, how to get the date of an event in a post?
I am using ai1ec calendar 2.5.11. The plugin allows you to create events and set their start dates (an event can be recurring and have multiple start dates). I'm interested in how to use the start date of the event in the body of the post (for example, in the entry form header or in subheadings), when only one event with one wysiwyg is created in the admin panel, but since it is repetitive and has several start dates, several posts are created? I asked the developers about the availability of shortcodes, to which I received a negative response.
Screenshots for example:
Answer the question
In order to leave comments, you need to log in
Solved, we need to add the shortcode below to the theme's functions.php. As a result, [ev_date id="post number"] will display the start date of the event opened by the user.
function date_from_db( $atts ) {
date_default_timezone_set('Europe/Moscow');
$id = $atts['id'];
global $wpdb;
$id2 = (int) $_GET['instance_id'];
$q = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ai1ec_event_instances WHERE post_id='".$id."' ".(!empty($id2 )?" AND id='" .$id2."'":""), ARRAY_A);
return date('dm h:i', $q[0]['start']);
}
add_shortcode( 'ev_date', 'date_from_db' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question