functions.php
<?php
//
// CUSTOM FILTER TO ADD COMMA AFTER TAXONOMY OUTPUT FOR FIELD EDITOR
//
//
add_filter( 'field_editor_output_no_wrap_after', 'mysite_check_if_need_to_output_csv', 10, 6 );
function mysite_check_if_need_to_output_csv( $separator, $field_slug, $job_id, $field_values, $args, $single_value ){
// ADD ANY ADDITIONAL META KEYS TO USE WITH COMMAS BELOW
$csv_meta_keys = array( 'job_skill', 'qualification_tag' );
// If meta key is not one of our meta keys from above, return the default separator
if( ! in_array( $field_slug, $csv_meta_keys ) ) return $separator;
$last_value = end( array_values($field_values) );
if( ! empty( $single_value ) && $last_value !== $single_value ) {
return ', ';
} else {
return '';
}
}
No comments yet.