Get a free advice now!

    Pick the topic

    Developer OutsourcingWeb developingApp developingDigital MarketingeCommerce systemseEntertainment systems

    Thank you for your message. It has been sent.

    Tags

    Events Calendar – upcoming events widget

    Events Calendar – upcoming events widget

    The Events Calendar is a powerful plugin for creating events and embedded calendar views on WordPress.

    The basic version is free to download from the official WP repo: https://wordpress.org/plugins/the-events-calendar/

    There are over 20 functionalities presented on its list of features, including a plethora of hooks and filters, Google Maps integration, Google Calendar and iCal exporting, saved venues and organizers, the ability to rapidly search for or create specific events, and more. It works smoothly across all platforms – desktop PCs, smartphones and tablets – and the in-depth tutorial will clear out most, if not any, potential doubts. All of this resulted in the rating of 4.4/5 stars with over 1800 submitted reviews. The developers continue to improve the tool as the popularity of the plugin is steadily growing (800,000+ active installations as of January 2021).

    The plugin offers a lot of functions, but lacks displaying upcoming events. Below is a custom snippet for displaying the “Upcoming events widget” for the next 14 days. To render data, we’re using a built-in plugin shortcode [tribe:event-details]

    function ctGetUpcomingEvents( $limit = '+7 days' ) 
    
    {  
       $now =  date('Y-m-d');
         $start_date =  date('Y-m-d', strtotime($now));
         $end_date = date('Y-m-d', strtotime($limit , strtotime($start_date)));
         // show upcoming events 
         $args = [
             'post_type'   => 'tribe_events',
             'post_status' => 'publish',
             'meta_query'  => [
                 'relation'      => 'AND',
                 'starts_after'  => [
                     'key'     => '_EventStartDate',
                     'compare' => '>',
                     'value'   => $start_date,
                 ],
                 'ends_before' => [
                     'key'     => '_EventStartDate',
                     'compare' => '<',
                     'value'   => $end_date,
                 ],
             ],
             'meta_key' => '_EventStartDate',
             'orderby' => 'meta_value',
             'order' => 'ASC',
         ];
         return get_posts($args); 
     }
     function ctRenderUpcomingWidget(){
         $events = ctGetUpcomingEvents('+14 days' );
         foreach ($events as $item) { 
             echo '<h2>'. $item->post_title . '</h2>';
             echo do_shortcode('[tribe:event-details id="'. $item->ID .'"]');
         }
     }
    
     // to render - paste into PHP template:
     ctRenderUpcomingWidget();
    Comments
    0 response

    Add comment

    Your email address will not be published. Required fields are marked *

    Popular news

    Digital marketing without third-party cookies – new rules
    • Technology
    • Trends

    Digital marketing without third-party cookies – new rules

    February 21, 2024 by createIT
    eCommerce healthcheck
    • Services
    • Trends

    eCommerce healthcheck

    January 24, 2024 by createIT
    Live Visitor Count in WooCommerce with SSE
    • Dev Tips and Tricks

    Live Visitor Count in WooCommerce with SSE

    December 12, 2023 by createIT
    Calculate shipping costs programmatically in WooCommerce
    • Dev Tips and Tricks

    Calculate shipping costs programmatically in WooCommerce

    December 11, 2023 by createIT
    Designing a cookie consent modal certified by TCF IAB
    • Dev Tips and Tricks

    Designing a cookie consent modal certified by TCF IAB

    December 7, 2023 by createIT
    Understanding the IAB’s Global Vendor List (GVL)
    • Dev Tips and Tricks

    Understanding the IAB’s Global Vendor List (GVL)

    December 6, 2023 by createIT
    Effortlessly transform JSON data into a clear schema
    • Uncategorized

    Effortlessly transform JSON data into a clear schema

    December 5, 2023 by createIT

    Support – Tips and Tricks
    All tips in one place, and the database keeps growing. Stay up to date and optimize your work!

    Contact us