• Hi,

    I would like to show a list of upcoming events as in the below link under “Our Programs” section with the immediate upcoming one highlighted on the left side and the list on the right side with the option of vertical scrolling.

    https://www.jkyog.org/

    Someone please guide me on how to accomplish this, using free version of Events Manager. In case if it is not feasible with this, are there any alternatives available to accomplish this without having to go for paid plugins or extensions.. Any help would be highly appreciated.

Viewing 11 replies - 16 through 26 (of 26 total)
  • Thread Starter sanumolu5

    (@sanumolu5)

    @joneiseman

    I am using Elementor Posts widget. I do not see scope in it. Is there a work around or an alternative where I can include this?

    If you’re using the Elementor Posts Widget Pro you can specify Date to be “All” (note that this date refers to the date the post was published, not the event start date). You will need to use their Custom Query Filter to order by the event start date. This lets you use the full power of WP_Query to control which posts are displayed. Here’s what you might use as an argument to WP_Query:

    $args = array(
        'post_type' => 'event',
        'meta_key' => '_event_start_date',
        'meta_type' => 'DATE',
        'orderby' => 'meta_value',
        'order' => 'DESC',
    );

    Here’s how to do the equivalent using Elementor Posts Query Pro and the Custom Query Filter:

    // Create a custom query filter.
    function my_custom_query_filter($query) {
        // Set the post type to post.
        $query->set('post_type', 'event');
    
        // Set the meta key to _event_start_date.
        $query->set('meta_key', '_event_start_date');
    
        // Set the meta type to DATE.
        $query->set('meta_type', 'DATE');
    
        // Set the orderby to meta_value.
        $query->set('orderby', 'meta_value');
    
        // Set the order to DESC.
        $query->set('order', 'DESC');
    
        // Return the query.
        return $query;
    }
    
    // Add the custom query filter to the Elementor Pro post widget.
    add_filter('elementor/widgets/post/query', 'my_custom_query_filter');
    • This reply was modified 1 year, 4 months ago by joneiseman.
    • This reply was modified 1 year, 4 months ago by joneiseman.
    Thread Starter sanumolu5

    (@sanumolu5)

    @joneiseman

    That was awesome. It worked. It actually filtered out all the events and is showing future events.

    On the right side I am using post title and calling shortcodes to get data of that post. However, here I am not able to filter out to get only future post titles. I don’t see a custom query filter for Post title widget. Any ideas how this can be accomplished?

    • This reply was modified 1 year, 4 months ago by sanumolu5.

    The post title widget is for use on the single event page. It isn’t used to display a list of events. For displaying a list of posts you could use a different widget like the Query Loop Grid or the Query Posts Widget or the Archive Posts Widget.

    I don’t own Elementor Pro so I can’t experiment with this.

    Thread Starter sanumolu5

    (@sanumolu5)

    @joneiseman

    I realized that I had overlooked the option to use a custom query filter while using the Query Loop Grid. My apologies for missing that.

    Regarding my remaining requirement, I would like to have the ability to open the custom URL assigned to the event when clicking on the image or “Read More” button within the Posts Widget. Is there a way to accomplish this using Posts Widget itself? (Currently it is taking to the default event details page provided by Events Manager on click of either of the link)

    • This reply was modified 1 year, 4 months ago by sanumolu5.

    You would like to know how to change the URL when clicking on the image or the “Read More” when using Elementor Pro Posts Widget. I don’t have a copy of Elementor Pro so I can’t look at the php code to see if there’s a filter that could be used to do that. I would ask Elementor Pro customer support or go to their community forum and ask the question their.

    Let’s say you created a custom event attribute #_ATT{EVENTURL} then the following code snippet should replace the link to the event with the value of #_ATT{EVENTURL} for that event:

    add_filter( 'post_type_link', 'my_em_eventlink', 10, 2 );
    function my_em_eventlink( $post_link, $post ) { 
        if ( $post && $post->post_type == 'event' ) {
            $url = get_post_meta( $post->ID, 'EVENTURL', true);
            if ( !empty( $url ) )
                return $url;
        } 
        return $post_link;
    }
    • This reply was modified 1 year, 4 months ago by joneiseman.

    I’m struggling with the code above. I’d like to have future events in an elementor pro carousel loop together with events manager free version.

    When I use your code above and I modified it to filter with current_date:

    // Create a custom query filter.
    function my_custom_query_filter($query) {
    	$current_date = current_time('Y-m-d');
        // Set the post type to post.
        $query->set('post_type', 'event');
    
        // Set the meta key to _event_start_date.
        $query->set('meta_key', '_event_start_date');
    
        // Set the meta type to DATE.
        $query->set('meta_type', 'DATE');
    
        // Set the orderby to meta_value.
        $query->set('orderby', 'meta_value');
    
        // Set the order to DESC.
        $query->set('order', 'DESC');
    
    	$query->set( 'meta_compare', '>=');
    	
    	$query->set( 'meta_value', $current_date);
    	
        // Return the query.
        return $query;
    }
    
    // Add the custom query filter to the Elementor Pro post widget.
    add_filter('elementor/query/future_events', 'my_custom_query_filter');

    I don’t know, what is wrong with it, but I can’t see any filter function in it. Maybe you can have a look at this?

    It all looks correct to me. I don’t have Elementor Pro to test this.

    Did you specify the query_id in the posts widget to be “future_events” (without the quotes)?

    https://developers.elementor.com/docs/hooks/custom-query-filter/

    Try setting it to this:

    	$current_date = current_time('Y-m-d');
            // Set the post type to post.
            $query->set('post_type', 'event');
    	// Get current meta Query
    	$meta_query = $query->get( 'meta_query' );
    
    	// If there is no meta query when this filter runs, it should be initialized as an empty array.
    	if ( ! $meta_query ) {
    		$meta_query = [];
    	}
    
    	// Append our meta query
    	$meta_query[] = [
    		'key' => '_event_start_date',
    		'value' => $current_date,
    		'compare' => '>=',
    	];
    
    	$query->set( 'meta_query', $meta_query );
            $query->set('meta_type', 'DATE');
            $query->set('orderby', 'meta_value');
    • This reply was modified 1 year, 1 month ago by joneiseman.

    You made my day!
    The last one is now working, but I don’t understand everything on this snippet. It seems, that the missing $meta_query has to be initialized first.

    So here is my code, which is working now:

    function my_custom_query_filter($query) {
    $current_date = current_time('Y-m-d');
    // Set the post type to post.
    $query->set('post_type', 'event');
    // Get current meta Query
    $meta_query = $query->get( 'meta_query' );
    
        // If there is no meta query when this filter runs, it should be initialized as an empty array.
        if ( ! $meta_query ) {
            $meta_query = [];
        }
    
        // Append our meta query
        $meta_query[] = [
            'key' => '_event_start_date',
            'value' => $current_date,
            'compare' => '>=',
        ];
    
        $query->set( 'meta_query', $meta_query );
            $query->set('meta_type', 'DATE');
            $query->set('orderby', 'meta_value');
    }
    
    add_filter('elementor/query/future_events', 'my_custom_query_filter');
Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘Upcoming events with free version’ is closed to new replies.