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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.