Home Forums Bug Reports Orderby ACF custom value


Orderby ACF custom value

  • I may be doing this incorrectly, or the docs may not be up to date. Either way i wanted to open the topic up for discussion. The docs state to order a query by a custom value created in ACF you use the following:

    // args
    $args = array(
    	'post_type'		=> 'event',
    	'posts_per_page'	=> -1,
    	'meta_key'		=> 'start_date',
    	'orderby'		=> 'meta_value_num',
    	'order'			=> 'DESC'
    // query
    $wp_query = new WP_Query( $args );
    // loop
    while( $wp_query->have_posts() )
    	// ...

    This does not work for me using ACF Pro v 5.0.7.

    However, this does order properly:

    'orderby' => 'meta_value',

    changing meta_value_num to meta_value.

    Did I misunderstand the docs, or is the latter the proper way to do it currently?

Viewing 1 post (of 1 total)

The topic ‘Orderby ACF custom value’ is closed to new replies.