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.


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
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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