Wednesday, October 16, 2024

Past webinar list (WebinarPress)

List of past webinars:

// Past webinars shortcode
function regf_display_past_webinars() {
$args = array(
'post_type' => 'wswebinars',
'posts_per_page' => -1,
'meta_key' => '_wswebinar_gener_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_wswebinar_gener_date',
//'value' => date('Y-m-d H:i:s'),
// Compare with the current date to get past webinars
'value' => date('Y-m-d'),
'compare' => '<',
// Get webinars that occurred before the current date
'type' => 'DATETIME',
),
),
);

$query = new WP_Query($args);
$posts = $query->posts;

ob_start();
echo '<ul>';
echo '<h2 class="widget-title">Past Webinars</h2>';
if ($posts) {
foreach ($posts as $post) {
//echo '<a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a><br>';
$meta_values_past_date = get_post_meta($post->ID,
'_wswebinar_gener_date', true);
$meta_values_vurl = get_post_meta($post->ID,
'_wswebinar_livep_vidurl', true);
echo get_the_title($post->ID) . ' ('. $meta_values_past_date .')' . ' - '
. '<a href="'. $meta_values_vurl .'">' . 'Watch webinar' . '</a>' . '<br>';
}
}
else {
echo 'No past webinar';
}
echo '</ul>';
return ob_get_clean();
}
add_shortcode('past_webinars', 'regf_display_past_webinars');


No comments:

Post a Comment

Upcoming webinar list (WebinarPress)

Upcoming webinar list (WebinarPress) // Upcoming webinars shortcode function regf_display_upcoming_webinars () { $args = array ( ...