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

    A game changer for WooCommerce users
    • Our Highlights

    A game changer for WooCommerce users

    March 24, 2023 by createIT
    The differences between a web app and a mobile app
    • Services
    • Technology
    • Trends

    The differences between a web app and a mobile app

    March 7, 2023 by createIT
    Webrooming and showrooming
    • Trends

    Webrooming and showrooming

    February 14, 2023 by createIT
    PHPStorm – fix long load time of a directory window
    • Dev Tips and Tricks

    PHPStorm – fix long load time of a directory window

    January 20, 2023 by createIT
    reCAPTCHA v3 – WordPress implementation
    • Dev Tips and Tricks

    reCAPTCHA v3 – WordPress implementation

    January 20, 2023 by createIT
    How to compare GIT and server files
    • Dev Tips and Tricks

    How to compare GIT and server files

    January 19, 2023 by createIT
    How to trigger a click event inside iframe?
    • Dev Tips and Tricks

    How to trigger a click event inside iframe?

    January 19, 2023 by createIT
    FOOEvents – generate a custom CSV report
    • Dev Tips and Tricks

    FOOEvents – generate a custom CSV report

    January 19, 2023 by createIT
    Headless chrome – testing webgl using playwright
    • Dev Tips and Tricks

    Headless chrome – testing webgl using playwright

    January 18, 2023 by createIT
    Preview big SQL files with PilotEdit
    • Dev Tips and Tricks

    Preview big SQL files with PilotEdit

    January 18, 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