A general theory of thermoacoustics is derived for arbitrary stack pores. Previous theoretical treatments of porous media are extended by considering arbitrarily shaped pores with the only restriction that the pore cross-sections vary slowly in the longitudinal direction. No boundary-layer approximation is necessary. Furthermore, the model allows temperature variations in the pore wall. By means of a systematic approach based on dimensional analysis and small parameter asymptotics, we derive a set of ordinary differential equations for the mean temperature and the acoustic pressure and velocity, where the equation for the mean temperature follows as a consistency condition of the assumed asymptotic expansion. The problem of determining the transverse variation is reduced to finding a Green's function for a modified Helmholtz equation and solving two additional integral equations. Similarly the derivation of streaming is reduced to finding a single Green's function for the Poisson equation on the desired geometry. © Cambridge University Press 2008.