WordPress.org

Ready to get started?Download WordPress

Forums

Event Organiser
[resolved] Change list order of events in archive-event.php (11 posts)

  1. McTomTom
    Member
    Posted 2 years ago #

    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.

    http://wordpress.org/extend/plugins/event-organiser/

  2. Stephen Harris
    Member
    Plugin Author

    Posted 2 years ago #

    Hi McTomTom,

    You might want to see this thread :).

  3. McTomTom
    Member
    Posted 2 years ago #

    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.

  4. Stephen Harris
    Member
    Plugin Author

    Posted 2 years ago #

    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,

    add_action('pre_get_posts','wpse50761_alter_query',5);
    function wpse50761_alter_query($query){
    
          if( $query->is_main_query() && is_post_type_archive('event') ){
              $query->set('order','DESC');
          }
    }

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

  5. McTomTom
    Member
    Posted 2 years ago #

    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)? ;)

  6. Stephen Harris
    Member
    Plugin Author

    Posted 2 years ago #

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

    add_action('pre_get_posts','wpse50761_alter_query',15);
    function wpse50761_alter_query($query){
          if( $query->is_main_query() && is_post_type_archive('event') ){
    	$query->set('orderby','eventstart');
    	$query->set('order','desc');
          }
    }
  7. McTomTom
    Member
    Posted 2 years ago #

    Yeahhhh! It works: http://niasony.com/en/events/event/ :)

    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.

  8. McTomTom
    Member
    Posted 2 years ago #

    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.

  9. alfalipo
    Member
    Posted 1 year ago #

    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?

    Thanks

  10. McTomTom
    Member
    Posted 1 year ago #

    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:

    <?php

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

    add_action('pre_get_posts','wpse50761_alter_query',15);
    function wpse50761_alter_query($query){
    if( $query->is_main_query() && is_post_type_archive('event') ){
    $query->set('orderby','eventstart');
    $query->set('order','DESC');
    }
    }

    /**
    * and from here goes the original script - hope it helps :)

    Tom

  11. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    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: http://codex.wordpress.org/Child_Themes#Using_functions.php ).

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic