Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1275847

    Hi,
    I would like to show Events form the events calendar in the masonry, so far so good. However, past events should not be visible and events should sort by start date of the event.
    I found 3 posts about it, both with the same filter, see below.
    https://kriesi.at/support/topic/enfold-masonry-blog-modern-tribe-calendar-other-posts/
    https://kriesi.at/support/topic/the-events-calendar-and-masonry-sorting/
    https://kriesi.at/support/topic/problems-with-masonry-element-with-the-events-calendar/

    The filter helps to hide the events that are over but the sorting isn’t going well. Could you have a look and let me know what is wrong.
    Thanks in advance!
    Regards,
    Ariane

    /* MODERN TRIBE CALENDAR FILTER*/
    add_filter(‘avia_masonry_entries_query’, ‘avia_masonry_entries_query_mod’, 10, 2);
    function avia_masonry_entries_query_mod( $query, $params ) {
    $eventquery = array(‘paged’=> false, ‘eventDisplay’ => ‘list’);
    $upcoming = Tribe__Events__Query::getEvents( $eventquery, true);
    $include = array();
    
    foreach($upcoming->posts as $key => $event) {
    $include[] = $event->ID;
    }
    if(is_page(9002)) {
    $query[‘post__in’] = $include;
    }
    return $query;
    }
    /* END MODERN TRIBE FILTER*/
    #1276681

    Hey ariane1001,

    Sorry for the delay. Try to adjust the $eventquery so that the items are sorted by events date, so..

    $eventquery = array(‘paged’=> false, ‘eventDisplay’ => ‘list’);
    

    .. should be adjusted to.

    $eventquery = array(‘paged’=> false, 'orderby'= => 'event_date', 'order'                => 'ASC',);
    

    Best regards,
    Ismael

    #1277183

    Hi Ismael,
    Thanks for your answer.
    I got some erorrs on the syntacs en I changed it to
    $eventquery = array('paged'=> false, 'orderby' => 'event_date', 'order' => 'ASC');

    But it’s not working? Could you take another look?
    I added a temporary login below.

    Thanks in advance,
    ARiane

    #1277516

    Hi,

    Thank you for the update.

    We adjusted the value of the is_page function so it uses an array.

    if(is_page(array(197, 3636, 4555))) {
    

    We also created a test page. (see private field)

    Best regards,
    Ismael

    #1279155

    Thanks,
    But it is still not working?
    – Events in de past are still visible?
    – Events are still shown by publication date in stead of by startdate of the event?
    So is it possible to get the code working or is it not working anymore with the latest versions of Enfold?
    I extended the login so you can still take a look if you want.
    Thanks in advance,
    Regards,
    ARiane

    #1279769

    Hi,

    Would you mind providing access to the file server so that we could test this properly? Please post the login details in the private field.

    Thank you for your patience.

    Best regards,
    Ismael

    #1279784

    Hi Ismael,
    Below the link to the fileserver. You should be logged in strait away, if not let me know.
    Regards, Ariane

    #1280050

    Hi,

    Thank you for the info.

    Unfortunately, we get a HTTP/1.1 401 Unauthorized error when we try to access the link above. Would you mind creating an FTP account instead so that we could use an FTP client? Please include the WP info in the private field as well.

    Best regards,
    Ismael

    #1280089
    This reply has been marked as private.
    #1280546

    Hi,

    Thank you for the info.

    We modified the code a bit and use the tribe_get_events function instead of forming a new query. Only the upcoming events are not displaying in the front end. (see private field)

    /* The evens calendar order */
    function avia_masonry_entries_query_mod( $query, $params ) {
    	$include = array();
    
    	$events = tribe_get_events( [
    		'posts_per_page' => $query["posts_per_page"],
    		'start_date'     => 'now',
    	] );
    
    	foreach($events as $event) {
    		$include[] = $event->ID;
    	}
    
    	if(is_page(array(197, 3636, 4555))) {
    		unset($query['tax_query']);
    	        $query['post__in'] = $include;
    	}
    
    	return $query;
    }
    add_filter('avia_masonry_entries_query', 'avia_masonry_entries_query_mod', 10, 2);
    

    Best regards,
    Ismael

    #1283395

    Hi Ismael,
    Thank you very much. It is working now, even on the homepage. I had to adjust the order there and then it went perfect.
    Very glad with the new code.
    Thanks again,
    Best regards,
    Ariane

    #1283584

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘enfold masonry sort by date in the events calendar’ is closed to new replies.