Only the person who is obligated to the loan will have their credit affected. Typically the foreclosure suit mentions all the owners and anybody else who might have a security interest, but that is just to put them on notice that they are losing their ownership in the proceedings.
Of course, if you are married, you may find it difficult obtaining loans with one of you with bad credit even if the other is clean.