Support » Plugin: Event Organiser » [Plugin: Event Organiser] Change list order of events in archive-event.php

  • Resolved McTomTom


    Hi, I would like to display the event list on the default template “archive-event.php” in a DESC instead of the default ASC order. I’ve already created a child instance of the page in my themes folder. And I’ve already learned that there is a “eo_get_event” function. But i’m totally lost, where to put in the function in the php code of the archive-event.php file (if this is the right way to do it?!). Can anyone help me? Sorry, I know that this is a dummy question – but it would be great, if I would know how to manage this Dummy-problem. Thank you in advance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi McTomTom,

    You might want to see this thread :).

    Hi Stephen, thanx a lot for your fast reply. Unfortunately it doesn’t work for me. I copied the code (add_action(‘pre_get_posts’, …) in my themes function.php – but all what i get is a php error. What am I doing wrong? Should I take another file? Sorry, but I’m lost here again …

    May I make a wish for a checkbox in the PlugIns settings – similar to the one Dropdown ASC/DESC in the widgets? 😉

    Anyway, the Event Organiser PlugIn is the only one of 5, which is working correctly with my Responsive Theme and WPML (3 languages)!!!! :9 I only had to do a few simple modifications in the themes templates.

    Yup, modifications to the templates are expected (even strongly encouraged!). The layout/content is completely in your control :).

    As for the pre_get_posts, I’ll post the code here as well,

    function wpse50761_alter_query($query){
          if( $query->is_main_query() && is_post_type_archive('event') ){

    I will double check this later when I can, but everything looks ok there. What php error are you getting?

    Hey Stephen, first – I should have read the comment in the responsive themes function.php in the root:

    * WARNING: Please do not edit this file in any way
    * load the theme function files
    require ( get_template_directory() . ‘/includes/functions.php’ );

    So i modified functions.php in folder includes. No php error furthermore, but no effect on the sorting. I put the code in at the beginning and in the end. So I’m still lost

    Would it in some way help, if i would post the whole sitecode here (about 550 raws)? 😉

    Ok I’ve looked into it, you need to set an ‘orderby’ as well:

    function wpse50761_alter_query($query){
          if( $query->is_main_query() && is_post_type_archive('event') ){

    Yeahhhh! It works: 🙂

    Thank you so much for your engagement and your patience, Stephen. Great support! And again: It’s a great PlugIn and the only one I know out of the popular five Event PlugIns, which works with Responsive Theme and Multi language for me.

    One annotation: In “Responsive Theme” the right “function.php” to edit is not the one in root, but in subfolder “includes”. It seems not to work, if I create a duplicate of this folder and the php-file in my child theme root. As far as I know, you have to exchange the file in the parent themes folder. A backup of this site is recommended, because it will be overwritten by the next theme update.

    Hi, I experienced same problem with McTomTom above, and tried all solutions listed here but it doesn’t seems to work. Tried to place code on all function.php file but doesn’t affect at all. Could you give me explanation about this?


    Hi alfalipo,

    i found following solution for my “responsive” theme. Unfortunately you have to paste a little script into the functions.php (Theme functions) which is inside the themes folder “includes” . It doesn’t work in the child theme – so you have to put it in again every time you update your theme. But it works. But be careful: don`t change the functions.php in the root folder of your theme – its, as i said, inside the subfolder includes. Simply put in this scrip directly at the top after the php code starts:


    // Exit if accessed directly
    if ( !defined(‘ABSPATH’)) exit;

    function wpse50761_alter_query($query){
    if( $query->is_main_query() && is_post_type_archive(‘event’) ){

    * and from here goes the original script – hope it helps 🙂


    Alfalipo, Tom

    You should put the code in your child theme’s functions.php – this should be at the root of the child theme (if it doesn’t have one, create it). This is loaded before the parent’s theme’s functions.php (see Codex: ).

    If that’s what you’re tried, I’m not sure what parent themes can do to make it not work when you do that (but sometimes themes do really bizarre things).

    @tom – I’m not sure why using functions.php in the root (its with an ‘s’ right?) doesn’t work for you, but it really should!

    But really, doesn’t matter where you put it, as long as the code is executed sometime before the main query. But for convenience, child theme is recommended.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Event Organiser] Change list order of events in archive-event.php’ is closed to new replies.