{
'readyState': '0',
'responseText' :'',
'status': '0',
'statusText': 'error'
}
add_action('acf/save_post', 'my_acf_save_option_page', 20);
function my_acf_save_option_page() {
$screen = get_current_screen();
if (strpos($screen->id, "theme-settings") == true) {
while( have_rows('field_615da6bb58108', 'option') ) {
the_row();
$val = get_sub_field('value');
$vals[] = get_sub_field('value'); //поля в форме
wp_insert_term($val, 'okna-city');
}
$terms = get_terms( array(
'taxonomy' => 'okna-city',
'hide_empty' => false
));
foreach ( $terms as $term ) {
$term_name = $term->name;
$term_name_s[] = $term_name; //текущие термины
}
//сравниваем
$c1 = array_diff($vals, $term_name_s);
$c2 = array_diff($term_name_s, $vals);
$outputs = array_merge($c1, $c2);
foreach ( $outputs as $output ) {
$term_id = get_term_by('name', $output, 'okna-city')->term_id;
wp_delete_term( $term_id, 'okna-city');
}
}
}
<li class="mix category<?php $terms = get_the_terms( $post->ID, 'genretax' );
if( $terms ){
$term = array_shift( $terms );
echo $term->term_id;
} ?>">
//...
</li>