Events Calendar – upcoming events widget


Events Calendar – upcoming events widget


Display upcoming events widget (The Events Calendar v.
Create custom wp_query and global function in functions.php

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:

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:


About the article Author:

Maciej Brzeziński

Techleader of createIT, working in the IT sector for over 14 years. Innovator, author, and owner of an e-shop that he has been continuously developing for over 10 years. Currently, with his team of over 20 developers, he supervises all kinds of e-commerce projects of varied structure, characteristics, and size: from simple on-line shops for retail clients to advanced B2B platforms with support of multiple shopping carts, multiple languages, and integration with external systems. His work also involves modifying and expanding the existing platforms with millions of products in their databases, platforms that support variable pricing (several variants of the same product), dropshipping modules, integration with storage systems, integration with courier delivery services, and the last but not least, the optimization of scripts. By participating in a multitude of projects, he had the opportunity to “test out” all kinds of platforms (open-source, SaaS – Cloud-Hosted eCommerce Platforms) and dedicated platforms.

About us:

Hi, we are createIT!

As a passionate group of professionals with a love for Web and mobile technologies, we have been successfully serving our clients for the past 15 years. Through these years we have continuously striven to create the best IT solutions our clients seek.

Our 70+ developer team creates cutting-edge complex B2B and B2C web systems and apps as well as delivers top-notch direct outsourcing services.

We work in multiple frameworks but we hold special feelings and are experts in PHP (Symfony, OXID, WordPress), JavaScript (React, AngularJS), Flutter and Blockchain. We do enjoy working in the scalable cloud environment like AWS.

We are located in Warsaw, Poland, in the heart of Europe. Concentrated on delivering durable web solutions of high integrity, we do not always try to be the cheapest. However, thanks to our location you will be surprised how reasonable our prices are.

Fluent in English we offer services worldwide. Among others, in countries such as the U.S.A., Great Britain, Germany, Australia, Sweden and Poland.

Popular News

Need help?

  • Looking for support from experienced programmers?

  • Need to fix a bug in the code?

  • Want to customize your webste/application?


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

createIT Contact