• I thought that would be easy but I cannot find how to use a different order for future/current and past events.

    What I want is for Future/Current events to order from the most recent to the future and for the Past events from the most recent to the past.

    I thought I could change this in settings -> Pages -> Event List/Archives and at Event Categories

    I use for both order by start date, start time, then event name. Ascending, Descending, Ascending

    I thought that the “Ascending, Descending, Ascending” was referring to “#_CATEGORYPASTEVENTS,?#_CATEGORYNEXTEVENTS,?#_CATEGORYALLEVENTS

    But now I think its only for the “start date, start time, then event name”

    I Read on Event List/Archives

    “These can be overridden when using shortcode or template tags.”

    How can I do that? Is there a filter I can use to simply order the past events from the most recent to the most distant to the past?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Byron Iniotakis

    (@orloxgr)

    Got it.

    In Events -> Settings -> Formatting (tab) -> Events Categories (accordeon)

    I put for past events:

    [events_list category=”#_CATEGORYPASTEVENTS” scope=”past” order=”desc” orderby=”event_start_date” pagination=1]

    Based on a message I found and changed a bit to fit my needs on this forum 1 year ago.

    Thread Starter Byron Iniotakis

    (@orloxgr)

    So the above does not work for all categories I guess I need to find a way to get current category id but it seems I cannot. Any help?

    Thread Starter Byron Iniotakis

    (@orloxgr)

    So I thought I would output the last segment of the URL into a shortcode and use this for the categories filter but in no avail.

    I use this in functions.php

    function get_last_url_segment() {
        $current_url = home_url($_SERVER['REQUEST_URI']);
        $url_segments = explode('/', trim(parse_url($current_url, PHP_URL_PATH), '/'));
        if (defined('ICL_LANGUAGE_CODE')) {
            $current_language = ICL_LANGUAGE_CODE;
            if (!empty($current_language)) {
                $url_segments = array_filter($url_segments, function($segment) use ($current_language) {
                    return $segment !== $current_language;
                });
            }
        }
        $last_segment = end($url_segments);
    
        return $last_segment;
    }
    add_shortcode('last_url_segment', 'get_last_url_segment',5);

    and in events manager:

    [events_list category="[last_url_segment]" scope='past' order='desc' orderby='event_start_date' pagination=1]

    But while the shortcode [last_url_segment] correctly outputs the slug outside their shortcode and if I enter it manually correctly picks up the category shortcode inside shortcode is not working.

    Thread Starter Byron Iniotakis

    (@orloxgr)

    So I think I got it. I used another function to nest the shortcodes

    function events_list_with_last_url_segment($atts) {
        $atts = shortcode_atts(
            array(
                'scope' => 'past',
                'order' => 'desc',
                'orderby' => 'event_start_date',
                'pagination' => 1,
            ),
            $atts
        );
    
        $last_url_segment = get_last_url_segment();
    
        $events_list_shortcode = "[events_list category='$last_url_segment' scope='{$atts['scope']}' order='{$atts['order']}' orderby='{$atts['orderby']}' pagination='{$atts['pagination']}']";
    
        $events_list_output = do_shortcode($events_list_shortcode);
    
        return $events_list_output;
    }
    add_shortcode('events_list_with_last_url_segment', 'events_list_with_last_url_segment');

    and in plugin:

    [events_list_with_last_url_segment]

    But ill leave this open in case someone has a better way.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Different order for Future and past events’ is closed to new replies.