Home › Forums › Backend Issues (wp-admin) › Bidirectional term-to-term relationship › Reply To: Bidirectional term-to-term relationship
I don’t know for sure, I think it may have something to do with this part of the code
// find the position of $post_id within $value2 so we can remove it
$pos = array_search($post_id, $value2);
// remove
unset( $value2[$pos] );
Maybe the value you’re getting for $pos is somehow incorrect or somehow does not translate to the correct index, but I can’t say for sure.
Generally, when I’m removing things from an array I build a new array rather than manipulate the existing array and it saves me a lot of headaches.
$new_array = array();
foreach ($old_array as $value) {
if (/*condition to keep value*/) {
$new_array[] = $value;
}
}
$old_array = $new_array;
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.