Make it possible to display all events in the calender

[ad_1]

On our site the users want to be able to see past events as well as upcoming events in the events calendar. But there is no hook to alter the args array that is sent to WP_Query. So we had to comment in the core file in order to get it as we want it. As you see below. It would be nice if you could add a apply_filter in this function.

This function is found in the file class-simple-event-planner-shortcode-event-calendar.php in \simple-event-planner\includes\shortcodes

public function sep_calendar_output($atts) {

    date_default_timezone_set('UTC');
    $current_time = strtotime(current_time('Y-m-d H:i:s', $gmt = 0));
    $count = 1;
    $seprator=",";

    // Default WP_Query Arguments 
    $args = array(
        'posts_per_page' => esc_attr($atts['events_limit']),
        'post_type' => 'event_listing',
        'post_status' => 'publish',
        //'meta_key' => 'event_start_date_time',
        //'meta_value' => $current_time,
        //'meta_compare' => '>=',
        'orderby' => 'meta_value',
        'order' => 'ASC',
    );

    // Extending Argument Array for Event Category
    if (isset($atts['event_category']) && '' !== $atts['event_category']) {
        $atts = explode(",", esc_attr($atts['event_category']));
        $args['tax_query'] = array(
            array(
                'taxonomy' => 'event_listing_category',
                'field' => 'slug',
                'terms' => esc_attr($atts['event_category']),
            ),
        );
    }

    // Search Address Meta Query 
    $meta_query = array('relation' => 'OR',);
    if (isset($atts['address']) && '' !== trim($atts['address'])) {
        $search_address = explode(",", $atts['address']);
        $meta_query[] = array(
            'key' => 'event_address',
            'value' => $search_address[0],
            'compare' => 'LIKE'
        );
    }

    // Extending Argument Array for Event Search
    $args['meta_query'] = $meta_query;
    $custom_query = new WP_Query($args);
    $published_posts = $custom_query->post_count;

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer