• My WP template is getting together slowly but surely, mainly because of the fantastic resources out there!

    I have a custom post type called ‘events’ that I use to display events on my index page, as well as on a specific agenda page. I use the custom fields ‘location’, ‘date’ and ‘time’. Obviously, I want my events to be sorted on date. However – the format I’m using is like this: 2nd February 2012 etc.

    Loop code

    <?php query_posts( 'post_type=events&posts_per_page=4&meta_key=datum&orderby=meta_value&order=ASC'); ?>
        <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

    Output code

    <?php
    $date = get_post_meta($post->ID, 'datum', true);
    if ($date){
    echo $date;
    }
    ?>

    Within a month my events are sorted OK. However as soon as an event enters from the next months, it will only look at the number for sorting. I need to find a way to convert my date (or to enter a date) so that WordPress sorts the posts on a different date-formatting compared to what is outputted…..But so far, I haven’t been able to do that with my custom-fields. I tried a lot of tutorials, but they all use a different time-formatting.

    Anyone has suggestions that might solve this small but significantly annoying problem?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom field date input messes up sorting’ is closed to new replies.