Support

Account

Home Forums General Issues How to order by ACF select label instead of value?

Helping

How to order by ACF select label instead of value?

  • Custom query, trying to sort posts by the state selected on an ACF select field, but using the label instead of the value. Issue is right now I’m getting a few like Wisconsin (WI) coming before West Virginia (WV). Thanks!

    $args = array(
      'post_type' => 'center',
      'posts_per_page'  => -1,
        'meta_key'          => 'state',
        'orderby'           => 'meta_value',
        'order'             => 'ASC'
    );
  • You cannot use the label to order the fields. The labels are not stored in the meta value, only the values are. In this case your values and labels would need to match.

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

You must be logged in to reply to this topic.