Higher-dimensional solutions for Einstein-Maxwell equations that generalize the charged Nariai spacetime are obtained. The solutions presented here are made from the direct product of several 2-spaces of constant curvature. These solutions turn out to have many magnetic charges, contrary to the usual higher-dimensional generalization of the Nariai spacetime, which has no magnetic charge at all. These solutions are then used to generate black hole metrics. Finally, it is analyzed how these generalized Nariai solutions are modified in more general theories of gravity.