title: Column sorting for taxonomy admin table using Advanced Custom Fields
body: <p>I'm trying to get my admin columns on edit-tags.php to be sortable by ACF field value, but I'm missing something. I can click the column heading to sort the column, but it only sorts the table by tag name and not the ACF field value in the column. If anyone can help, I'd really appreciate it!</p>
  
  <p><strong>I have set up the columns that I want to add:</strong></p>
  
  <pre><code>/**
  * Add columns to the post_tags admin table
  */
  function add_post_tag_columns($columns){
    $columns['featured'] = 'Featured';
    $columns['order'] = 'Order';
    $columns['group'] = 'Group';
  
    // Remove description column from table
    unset( $columns['description'] );
    return $columns;
  }
  add_filter('manage_edit-post_tag_columns', 'add_post_tag_columns');
  </code></pre>
  
  <p><strong>I have set the value for the tags in each column:</strong>    </p>
  
  <pre><code>/**
  * Set values for new post_tags admin table columns
  */
  function add_post_tag_column_content( $content, $column_name, $term_id ){
    $term= get_term($term_id, 'post_tag');
  
    switch ( $column_name ) {
  
    // display the value of ACF fields
    case 'featured' :
      $content = the_field( 'kw_featured_tag', $term );
      break;
  
    case 'order' :
      $content = the_field( 'kw_tag_order', $term );
      break;
  
    case 'group' :
      $content = the_field( 'kw_group_tags', $term );
      break;
  
    }
    return $content;
  }
  add_filter('manage_post_tag_custom_column', 'add_post_tag_column_content', 10, 3);
  </code></pre>
  
  <p><strong>I have set up column sorting</strong></p>
  
  <pre><code>/**
  * Make columns on post_tags admin table sortable
  */
  function set_custom_post_tag_sortable_columns( $sortable_columns ) {
    $sortable_columns['featured'] = 'kw_featured_tag';
    $sortable_columns['order'] = 'kw_tag_order';
    $sortable_columns['group'] = 'kw_group_tags';
  
    return $sortable_columns;
  }
  add_filter( 'manage_edit-post_tag_sortable_columns', 'set_custom_post_tag_sortable_columns' );
  </code></pre>
  
  <p><strong>And here's where [I think] I'm having the issue:</strong></p>
  
  <pre><code>/**
  * Set up the orderby for the column sorting
  */
  function post_tag_custom_orderby( $query ) {
    if ( ! is_admin() )
      return;
  
    $orderby = $query-&gt;get( 'orderby');
  
    if ( 'featured' == $orderby ) {
      $query-&gt;set( 'meta_key', 'kw_feature_tag' );
      $query-&gt;set( 'orderby', 'meta_value_num' );
    }
    elseif ( 'order' == $orderby ) {
      $query-&gt;set( 'meta_key', 'kw_tag_order' );
      $query-&gt;set( 'orderby', 'meta_value_num' );
    }
    elseif ( 'group' == $orderby ) {
      $query-&gt;set( 'meta_key', 'kw_group_tags' );
      $query-&gt;set( 'orderby', 'meta_value' );
    }
  }
  add_action( 'pre_get_posts', 'post_tag_custom_orderby' );
  </code></pre>
  
  <p>If anyone could help narrow down what I've done wrong, I would be a very happy Wordpress developer :P. Thanks in advance!</p>
  
  <p>--</p>
  
  <p>Edit: Here's a couple screenshots of my admin table:</p>
  
  <p><a href="https://i.stack.imgur.com/1mQ3Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1mQ3Y.png" alt="Order - Ascending"></a></p>
  
  <p><a href="https://i.stack.imgur.com/QcIm5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QcIm5.png" alt="Order - Descending"></a></p>
  
  <ul>
  <li>Featured (kw_featured_tag) is a true/false</li>
  <li>Order (kw_tag_order) is a number field</li>
  <li>Group (kw_group_tags) is a
  checkbox array (I changed it to return an array and now I need to fix
  my code to get the list of items in the array to be displayed instead
  of just "array")</li>
  </ul>