WordPress.org

Forums

[Plugin: Event Calendar 3] Archives ordered by event dates (2 posts)

  1. borisrorsvort
    Member
    Posted 5 years ago #

    Hi,
    I've search many days to solve that.
    How can you tell the wordpress build in archive page to order your post by event_dates without create a page manually for each year?

    I've bee using PostList with the Ec3 plugin to display event on specific pages. But the clients wants to see all event per year ordered by events dates.

    Any idea?

  2. borisrorsvort
    Member
    Posted 5 years ago #

    Hi, i just got the answer from the support newsletter of ec3 and this does apparently the trick.

    Paste this code into your functions.php template file and let the magic do:

    function custom_rewrite_rules($rules) { 
    
    $custom_rules = array();
    
    $custom_rules['([0-9]+)/?$'] =
    'index.php?m=$matches[1]&ec3_listing=yes&order=asc';
    
    $custom_rules['([0-9]+)/([0-9]+)?$'] =
    'index.php?m=$matches[1]$matches[2]&ec3_listing=yes&order=asc';
    
    $custom_rules['([0-9]+)/([0-9]+)/([0-9]+)?$'] =
    'index.php?m=$matches[1]$matches[2]$matches[3]&ec3_listing=yes&order=asc';
    
    return $custom_rules + $rules;
    
    }
    
    add_filter('rewrite_rules_array','custom_rewrite_rules');

    Don't forget to Update your permalinks structure so it takes filter

    Thanks to Jonathan Alderson for this answer

Topic Closed

This topic has been closed to new replies.

About this Topic