• Hello,

    I have a custom field setup to display dates for an event, I’ve managed to get the custom fields to work (yippee). With the following code:

    $event_date is the custom field.

    <?php

    $event_date = get_post_meta($post->ID, ‘event_date’, true);
    if ($event_date) {
    echo ‘The event date is ‘. date(‘l, F j, Y’, strtotime($event_date));
    }
    ?>

    However, I need to get the code sort through event_date custom fields in ascending date order please. So on a page of posts for events, if there’s an event on such 2 July, 2016 it comes before an event on 9, September 2018.

    Many thanks

    James

  • The topic ‘Custom field date sorted, but how to sort in ascending order please’ is closed to new replies.