Home › Forums › ACF PRO › ACF taxonomy input text › Reply To: ACF taxonomy input text
Hi @solserpiente,
The conversion of text inputs to pst tags would only work for single value custom fields in which case you would need the following JQuery function for the implementation(it should go to your functions.php file):
<?php
function convert_custom_fields_to_tags(){ ?>
<script type="text/javascript">
jQuery(document).ready(function($){
// Create list of custom fields to add as tags on save
// (e.g. var custom_field_names = ['my_custom_field', 'my_other_custom_field', 'yet_another_custom_field'];)
var custom_field_names = [];
$('form#post').submit(function(){
if(custom_field_names.length > 0) {
var custom_field_values = [];
$('#postcustom tr[id^="meta-"]').each(function(){
var meta_id = $(this).attr('id').substring($(this).attr('id').indexOf('-')).replace('-','');
if ($.inArray($(':text[id="meta[' + meta_id + '][key]"]').val(), custom_field_names) !== -1) {
custom_field_values.push($('textarea[id="meta[' + meta_id + '][value]"]').val().toLowerCase());
}
});
var tags = custom_field_values.join(',');
$('#new-tag-post_tag').val(tags);
}
});
});
</script>
<?php }
add_action('admin_footer', 'convert_custom_fields_to_tags');
?>
You would then need to add the custom field names to the custom_field_names array as follows:
var custom_field_names = ['my_custom_field', 'my_other_custom_field'];
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.