Created
February 24, 2016 01:05
-
-
Save tripflex/7fa23b6250d74609b8a8 to your computer and use it in GitHub Desktop.
Output taxonomy as comma separated value (auto output, php, widget, shortcode) for WP Job Manager Field Editor
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 | |
// | |
// 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 ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment