Support

Account

Home Forums Front-end Issues Order by ACF Field

Helping

Order by ACF Field

  • I want to order by a ACF numeric field however i can’t seem to get it to work:

    $args = array(
                                        'posts_per_page' => 20,
                                        'category_name' => 'staff-' . $wp_query->queried_object->post_name,
                                        'meta_key' => 'scroller_order',
                                        'orderby' => 'meta_value',
                                        'type' => 'NUMERIC',
                                        'order' => 'ASC'
                                    );

    The ACF field is called scroller_order and it only allows numbers but I want to order by whatever the person puts in that field I can’t seem to get it to work.

  • Try with 'orderby' => 'meta_value_num'
    I think you can remove 'type' => 'NUMERIC'

    See more here

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.