The spaces $X$ in which every prime $z^\circ $-ideal of $C(X)$ is either minimal or maximal are characterized. By this characterization, it turns out that for a large class of topological spaces $X$, such as metric spaces, basically disconnected spaces and one-point compactifications of discrete spaces, every prime $z^\circ $-ideal in $C(X)$ is either minimal or maximal. We will also answer the following questions: When is every nonregular prime ideal in $C(X)$ a $z^\circ $-ideal? When is every nonregular (prime) $z$-ideal in $C(X)$ a $z^\circ $-ideal? For instance, we show that every nonregular prime ideal of $C(X)$ is a $z^\circ $-ideal if and only if $X$ is a $\partial $-space (a space in which the boundary of any zeroset is contained in a zeroset with empty interior).