• Resolved eng0el

    (@eng0el)


    I was searching for a short code that helps me directly show the events filtered based on their start and end date.

    I want to build 2 pages, one for upcoming events that takes all events with start date > today.

    And the second page is for previous events where end date < today.

    Can someone help me how to find these shortcodes??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Rita Kikani

    (@kikanirita)

    Hi @eng0el ,

    You need to apply “[events]” shortcode to get upcoming event list, but as you mention you want to show specific filtered event, for that you need to add some custom code in your theme functions.php file.

    add_filter('get_event_listings_query_args', 'custom_event_listings_query_args', 10, 2);
    
    function custom_event_listings_query_args( $query_args, $args){
    
        global $post;
    
        $page_id = $post->ID;
    
        $datetime=date('Y-m-d');
    
        if($page_id == 'Your upcoming events page id'){
    
            $date_search[] = array(
    
                'key'     => '_event_start_date',
    
                'value'   => $datetime,
    
                'compare' => '>',
    
            );
    
        }else if($page_id == 'Your second events page id'){
    
            $date_search[] = array(
    
                'key'     => '_event_end_date',
    
                'value'   => $datetime,
    
                'compare' => '<',
    
            );
    
        }
    
        $query_args['meta_query'][] = $date_search;
    
        return $query_args;
    
    }

    In above code, you need to pass page id in place of “Your upcoming events page id” and “Your second events page id”. I hope that this code will help you to resolve your query.

    Thank you.

    Thread Starter eng0el

    (@eng0el)

    Thank you @kikanirita !

    It worked perfectly, all the best!

    Thread Starter eng0el

    (@eng0el)

    @kikanirita

    I was wondering if you have a method to change the label ‘Events’ if let’s say I want to name them Congresses? Is there a php function?

    Plugin Author Rita Kikani

    (@kikanirita)

    Hello @eng0el ,

    One new feature is added for our upcoming version, there is one attribute added for [events] shortcode through which you can change the title.

    [events title="Congresses"]

    If you want this in urgent basis then please take latest version from our git repository : https://github.com/wpeventmanager/wp-event-manager/tree/3_1_37

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shortcodes for future and past events based on start and end dates’ is closed to new replies.