Support » Plugins » Sort Posts By Event Date

  • I’m in the process of building a website for a local actor/theatre performer, and he wants a ‘Shows’ section in his website. I figure the best way to do this is to point a menu item at a ‘Shows’ post category, and he can create a WordPress post for each show/event that he’s performing in. My only issue with this is that he isn’t going to necessarily add shows to the site in the order that they will be happening, but I’d like to display them in chronological/date order on the site.

    Keeping in mind that the client (mid 30’s male, average knowledge of computers and the internet) is going to be adding the shows himself, can anyone think of a relatively simple solution that will achieve this?

    Cheers,

    Chris

Viewing 5 replies - 1 through 5 (of 5 total)
  • Another thought I had was to create a custom form using Gravity Forms that contained all of the fields for an event (event, location, date, ticket price) and having him create events via a front end form that then publishes a post.

    My thinking behind this was that (somehow!) I could create a chronological number from the date entered (Aug 11, 2011, for example, would convert to 20110811), and then somehow sort the posts via this number. I have no idea whether this is possible, or if my thinking is totally flawed. Any advice would be very appreciated! šŸ™‚

    OK, so this code, placed immediately before if (havePosts()) in my category template does appear to affect the sort order of the posts:

    <?php query_posts($query_string . '&meta_key=sortdate&orderby=meta_value'); ?>

    I’ve created a custom field called ‘sortdate’ and in here have entered a numeric representation of the event date (June 23rd, 2011 is 20110623). Only issue is that it is sorting them in the wrong direction. The closest (in date) shows are at the bottom of the page, whilst the furthest ones are displayed at the top. If I can figure out how to reverse this order, I think this will be sufficient. Any thoughts?

    Cheers,

    Chris

    For anyone who’s interested, I solved the problem above with the following code:

    <?php query_posts($query_string . '&meta_key=sortdate&orderby=meta_value&order=asc' ); ?>

    By adding a custom field called sortdate to each post in the ‘Events’ category, and making the value of that field the date of the event in reverse order (YYYYMMDD), I was able to sort the posts as I required. šŸ™‚

    @chris H Thanks so much for posting this. I used this little bit of code to organize my blog posts by event date, rather than by date posted. Really handy little trick.

    Hi Chris H,

    Thanks for posting this.
    I’ve been having a similar problem and after playing around with some events plugins and having no luck, I decided to use your method.

    Is it possible to only show posts where the date is greater than or equal to the current date?
    i.e. not show posts/evnts that have already happened.

    I have tried the following method but am having no joy…

    <?php query_posts($query_string . ‘&meta_key=sortdate&meta_compare=>=meta_value=CURDATE()&meta_key=sortdate&orderby=meta_value&order=asc’ ); ?>

    Can anybody help on this one please?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sort Posts By Event Date’ is closed to new replies.