Hello I am using the suggested snippet here to add a new term to a dropdown menu: /
which is:
add_filter( 'job_application_statuses', 'add_new_job_application_status' );
function add_new_job_application_status( $statuses ) {
$statuses['example'] = _x( 'Example', 'job_application', 'wp-job-manager-
applications' );
return $statuses;
}
That works fine but my new single entry 'example' is output at the bottom of the dropdown list, I'd really like it to be in 2nd place. Is there a simple way to do this? Thank you.
Hello I am using the suggested snippet here to add a new term to a dropdown menu: https://wpjobmanager/document/applications-customising-application-statuses/
which is:
add_filter( 'job_application_statuses', 'add_new_job_application_status' );
function add_new_job_application_status( $statuses ) {
$statuses['example'] = _x( 'Example', 'job_application', 'wp-job-manager-
applications' );
return $statuses;
}
That works fine but my new single entry 'example' is output at the bottom of the dropdown list, I'd really like it to be in 2nd place. Is there a simple way to do this? Thank you.
You can achieve this by using the array_splice() function in conjunction with array_merge(). Here is an example:
function add_new_job_application_status( $statuses ) {
return array_merge(
array_splice( $statuses, 0, 1 ),
array( 'example' => _x( 'Example', 'job_application', 'wp-job-manager-
applications' ) ),
array_splice( $statuses, 1, -1 )
);
}
add_filter( 'job_application_statuses', 'add_new_job_application_status' );
This function takes the first item in the $statuses
array, your custom example field, the rest of the items in the array and merges it together. You need to do it this way as splice doesn't support inserting a multi-dimensional array at a specific point in an array. Hope that helps.