I've some posts used as occasions, having a custom area for that event's date. I am searching for ordering thoses posts by event's date (chronologically). I am wondering:

  • Can you really set the event's date custom area like a "date" format (for the time being, it is a simple type=text).
  • Howto order thoses posts basically always make use of the same format (like dd/mm/yyyy). I have to obtain the 3 close coming occasions (not the final 3).

Did wordpress includes a built-in function who could compare to start dating ? towards the present day date?


I simply did this! (www.wherewordsgo.com)

okay, i only first got it employed by 'pages' but.

but when you are making a meta box for 'deadline' after which place the date in yyyy/mm/dd format and add this for your functions.php it could help:

add_action('wp', 'check_page') function check_page () publish_sort', 'sort_it') add_filter('get_next_publish_sort', 'sort_it') add_filter('posts_orderby', 'sort_it' ) add_filter('posts_join', 'join_it' ) add_filter('posts_where', 'where_it' )

    function sort_it () {
        global $wpdb;

        return " $wpdb->postmeta.meta_value ASC ";

    function join_it( $join ) {
        global $wpdb;

        $join .= " LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) ";

      return $join;

    function where_it( $where ) {
        global $wpdb;
        $where .= "AND $wpdb->postmeta.meta_key = 'deadline' ";

      return $where;

I acquired that from some site (which i've lost the hyperlink for... large Wordpress dude though I believe) and transformed it as being needed. Like I stated it really works just for custom pages on my small build (I am utilizing a custom type), but might just work with everything should you alter the 'is_page()' function in the beginning to whatever is relative for you personally.

Hope that can help