这直接来自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
}