The selection rule of electrocyclization reactions is given in the original statement of the Woodward–Hoffmann rules.  If a generalized electrocyclic ring closure occurs in a polyene of 4n π-electrons, then it is conrotatory under thermal conditions and disrotatory under photochemical conditions.  Conversely in a polyene of 4n + 2 π-electrons, an electrocyclic ring closure is disrotatory under thermal conditions and conrotatory under photochemical conditions.
This result can either be derived via an FMO analysis based upon the sign of p orbital lobes of the HOMO of the polyene or with correlation diagrams.  Taking first the first possibility, in the ground state, if a polyene has 4n electrons, the outer p-orbitals of the HOMO that form the σ bond in the electrocyclized product are of opposite signs.  Thus a constructive overlap is only produced under a conrotatory or antarafacial process.  Conversely for a polyene with 4n + 2 electrons, the outer p-orbitals of the ground state HOMO are of the same sign.  Thus constructive orbital overlap occurs with a disrotatory or suprafacical process.
Additionally, the correlation diagram for any 4n electrocyclic reaction will resemble the diagram for the 4 electron cyclization of 1,3-butadiene, while the correlation diagram any 4n + 2 electron electrocyclic reaction will resemble the correlation diagram for the 6 electron cyclization of 1,3,5-hexatriene.
This is summarized in the following table: