Support

Account

Home Forums Feature Requests Sort Taxonomy Field SOLVED Reply To: Sort Taxonomy Field SOLVED

  • I actually patched the plugin to include this functionality.

    At line 211, I added the following:

        if($field['sort_order'] == 'alpha'){
          $sort_args = array(
            'orderby'      => 'name',
            'order'        => 'ASC',
          );
          array_push($args, $sort_args);
        }else if($field['sort_order'] == 'alpha_desc'){
          $sort_args = array(
            'orderby'      => 'name',
            'order'        => 'DESC',
          );
          $args = array_merge($args, $sort_args);
        }
    

    And at approx line 384 (after the last ‘field_option’), I added:

    <tr class="field_option field_option_<?php echo $this->name; ?>">
    	<td class="label">
    		<label><?php _e("Sort Order",'acf'); ?></label>
    	</td>
    	<td>
    		<?php
    		do_action('acf/create_field', array(
    			'type'		=>	'select',
    			'name'		=>	'fields['.$key.'][sort_order]',
    			'value'		=>	$field['sort_order'],
    			'choices'	=> array(
    				'alpha'	=>	__("Alpha Order Assending",'acf'),
            'alpha_desc'	=>	__("Alpha Order Desending",'acf'),
    				'id'		=>	__("Term ID",'acf')
    			)
    		));
    		?>
    	</td>
    </tr>

    I’ve attached the PHP file (as a txt file) for those that would like to see it.