WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I implemented a custom post type for a class post. Now every post has a additional date picker called "date_event", my question is: Any have ideas how can i order the post for the last date of the label date_event?

Thank you for your help.

share|improve this question
up vote 0 down vote accepted

This comes directly from the ACF documentation:

*  Order Posts based on Date Picker value
*  this example expects the value to be saved in the format: yymmdd (JS) = Ymd (PHP)

$posts = get_posts(array(
    'meta_key' => 'custom_order', // name of custom field
    'orderby' => 'meta_value_num',
    'order' => 'ASC'

if( $posts )
    foreach( $posts as $post )
        setup_postdata( $post );

        // ...


    wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly
share|improve this answer
But @micheele, can i show only the events in this weeks? – rodboc Feb 18 '13 at 16:07
That's possible though slightly more complicated (and a different question than what you asked above). First I'd get it showing all your posts ordered by your date field. Then post that code in a new question and ask how to limit the display by date range. – Michelle Feb 18 '13 at 17:43
Yes, you are right. Thanks for your help =) – rodboc Feb 18 '13 at 19:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.