Why “Warning: Invalid argument supplied for foreach()”
According to the documentation, get_the_terms() returns an array of WP_Term objects, or a boolean false value, or a WP_Error object. The last two won’t work with foreach(). You could update your code to check for these conditions: $orgs_in_post = get_the_terms($post[‘ID’], ‘company’); if ( is_array( $orgs_in_post ) ) { foreach ($orgs_in_post as $org_single) { array_push($recent_companies, $org_single->term_id); … Read more