Support » Plugin: The Events Calendar » Events calendar: Sort order in list view

  • Resolved Jake

    (@harpomarx-1)


    Hi,

    Is there any way to change the default sort order for the List view? By default, it is chronological, but I would like to show the events alphabetically; I want to edit the template for the list view (list/loop.php ?) but I am not sure how to get the events alphabetically.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author patriciahillebrandt

    (@patriciahillebrandt)

    Hey @harpomarx-1 ,

    Thank you for reaching out to us!

    You can order your events (in list view) alphabetically by adding the following snippet in the end of your theme’s functions.php file (without the <?php tag):

    https://gist.github.com/nefeline/fdf7bf7be695dd4a54d6c0796bcf1b20

    I hope this helps!

    Let me know if you need anything else.

    Regards,

    Patricia

    Jake

    (@harpomarx-1)

    Hi,

    I added the code but it doesn’t have any effect.

    Would it be because, as the Codex says:

    “Similarly, pre_get_posts will not work if used in template files (e.g., archive.php), since they are called after the query has been completed.” (from https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts )

    Or am I running into the same problem as here, that does not seem to be solved: https://theeventscalendar.com/support/forums/topic/order-of-events-showing-events-by-post-date/

    • This reply was modified 2 years, 4 months ago by Jake.
    Plugin Author Barry

    (@barryhughes-1)

    Similarly, pre_get_posts will not work if used in template files (e.g., archive.php), since they are called after the query has been completed.

    That sounds correct, but your theme’s functions.php file is not a template file as such (even though it lives inside of the theme directory) and it is loaded much earlier in the request.

    If that’s not working, though, you could try placing the code in a a custom plugin instead. Beyond that, I’m afraid we’re unable to go into much more depth on custom coding questions like this here in the free support forum – so while we’re happy to try and point you in the right direction for a change like this you’ll ultimately need to drive it to completion under your own steam.

    I do wish you luck, though – and please do feel free to share your final solution with the community ๐Ÿ™‚

    Plugin Contributor Courtney Engle Robertson

    (@courane01)

    Hey there! This thread has been inactive for a while so weโ€™re going to go ahead and mark it Resolved. Please feel free to open a new thread if any other questions come up and weโ€™d be happy to help. ๐Ÿ™‚

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Events calendar: Sort order in list view’ is closed to new replies.