Created
November 4, 2017 01:29
-
-
Save rahularyan/ce48a3aebc53823937b78cf47ced2f05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter select field. | |
* | |
* Check if select field options are terms and then change orderby and order value. | |
* This filter will work only with AnsPress 4.1.0 | |
*/ | |
function my_category_field_filter( $args, $form ) { | |
if ( 'select' === $args['type'] && 'terms' === $args['options'] ) { | |
$args['terms_args']['orderby'] = 'orderby'; | |
$args['terms_args']['order'] = 'DESC'; | |
} | |
return $args; | |
} | |
add_filter( 'ap_before_prepare_field', 'my_category_field_filter', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment