Endlosschleife kann nicht gefunden werden

Ich arbeite an der folgenden function, die schließlich eine Reihe von Beiträgen basierend auf Metadaten erstellen wird, die in einen “Eltern” -Post eingegeben werden. Ich stoße in eine Endlosschleife, wenn ich den Speicherknopf wp_update_post , was, wie ich weiß, oft durch die Verwendung von wp_update_post oder wp_save_post verursacht wird, während man sich in die save_post Aktion save_post . Ich habe die Aktion am Anfang der function vorübergehend entfernt und am Ende wieder hinzugefügt, um das zu verhindern, aber anscheinend nicht.

Kann jemand sehen, wo ich unten eine Endlosschleife verursache?

 function my_acf_save_post( $post_id ) { remove_action('acf/save_post', 'my_acf_save_post'); //remove action temporarily to prevent infinite loops! //All the dates saved in the repeater field $chosenDates = get_field('add_dates_and_times', $post_id); //timestamp //Get duration of event and multiply by 60 to get seconds $duration = get_field('event_duration', $post_id); //duration in minutes $duration = ($duration * 60); //duration in seconds //Get any event posts that have the ac_parent_id that matches the current parent post $currentChildEvents = get_posts(array( 'post_type' => 'tribe_events', 'meta_query' => array( array( 'meta_key' => 'ac_parent_post', 'meta_value' => $post_id, ) ), )); $hasChildren = have_posts($currentChildEvents); //true/false if ($hasChildren) { $existingDates = array(); while($hasChildren) { the_post(); $existingDate = get_post_meta(get_the_ID(), '_EventStartDate', true); $existingDates[] = strtotime($existingDate['0']); //timestamp } wp_reset_postdata(); } $datesNeedEvents = array_diff($chosenDates, $existingDates); //All the timestamps that need events created for them //check if the repeater has any values entered if (have_rows('add_dates_and_times', $post_id)) { update_post_meta($post_id, 'is_ac_parent_event', true); //Since we have some dates, make this event a parent update_post_meta($post_id, 'ac_child_dates', $chosenDates); //Set the array of child dates as a meta value in the parent post $count = 0; while (have_rows('add_dates_and_times', $post_id)) { //Loop through each date in repeater the_row(); $dateTime = get_sub_field('date_and_time'); //timestamp $startDate = date('Ym-d', $dateTime); $startHour = date('h', $dateTime); $startMinute = date('i', $dateTime); $startMeridian = date('a', $dateTime); $endStamp = ($dateTime+$duration); $endDate = date('Ym-d', $endStamp); $endHour = date('h', $endStamp); $endMinute = date('i', $endStamp); $endMeridian = date('a', $endStamp); $count++; if ($count == 1) { //This is the first date listed, so we update the parent post with its info $updateCurrent = array ( 'post_title' => get_the_title($post_id), //'post_content' => ac_get_the_content($post_id), 'EventStartDate' => $startDate, 'EventEndDate' => $endDate, 'EventStartHour' => $startHour, 'EventStartMinute' => $startMinute, 'EventStartMeridian' => $startMeridian, 'EventEndHour' => $endHour, 'EventEndMinute' => $endMinute, 'EventEndMeridian' => $endMeridian, ); tribe_update_event($post_id, $updateCurrent); } else { if (in_array($dateTime, $datesNeedEvents)) { $newEvent = array( 'post_title' => get_the_title($post_id), //'post_content' => ac_get_the_content($post_id), 'EventStartDate' => $startDate, 'EventEndDate' => $endDate, 'EventStartHour' => $startHour, 'EventStartMinute' => $startMinute, 'EventStartMeridian' => $startMeridian, 'EventEndHour' => $endHour, 'EventEndMinute' => $endMinute, 'EventEndMeridian' => $endMeridian, //'Venue' => array( //'Venue' => 'Some Place', // 'Country' => 'US', // 'Address' => '1 W. Washington Ave.', // 'City' => 'Madison', // 'State' => 'WI' //), ); $newEvent = tribe_create_event($newEvent); update_post_meta($newEvent, 'ac_parent_event', $post_id); } } } } else { //No dates present in repeater update_post_meta($post_id, 'ac_parent_event', false); //We set this to false, just in case it was true before } add_action('acf/save_post', 'my_acf_save_post'); //re-add action to continue if (!is_admin) { wp_redirect(get_bloginfo('url').'/events/community/edit/event/'.$post_id); exit; } } add_action('acf/save_post', 'my_acf_save_post', 20); 

Solutions Collecting From Web of "Endlosschleife kann nicht gefunden werden"