Support

Account

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;