Wednesday, October 16, 2024

Upcoming webinar list (WebinarPress)

Upcoming webinar list (WebinarPress)

// Upcoming webinars shortcode
function regf_display_upcoming_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-list-title">Upcoming 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="'. get_permalink($post->ID) .'">' . 'Join webinar' . '</a>' . '<br>';
wp_reset_query();
}
}
else {
echo 'No upcoming webinar';
}
echo '</ul>';
return ob_get_clean();
}
add_shortcode('upcoming_webinars', 'regf_display_upcoming_webinars');

No comments:

Post a Comment

Upcoming webinar list (WebinarPress)

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