Warning: Invalid argument supplied for foreach() in portfolio-list.php [closed]

It happens when the foreach() is fed with an invalid entry, because there is no term returned. To prevent this, wrap your loop inside a conditional:

// Get the terms( categories ) for the portfolio item
$terms = get_the_terms( $post_item->ID, 'portfolio_categories' );
if(is_array($terms) || is_object($terms)){
    foreach( $terms as $term ) {
    // some code here
    }
}

Now, the loop will only run only the post has some terms.