with almost anything in photography, there are compromises. The aperture that you use is no exception. the larger the aperture, the more contrast the lens produces, the smaller the aperture, the more d.o.f., up to a point.

usually the best aperture for maximum dof, and the minimum amount of diffraction, is going to be that which gives a working lens size of around 3mm to 5mm (focal length divided by aperture ie, 24/8=3). so with your zoom lens at 24mm, set to infinity, the f stop that is likely to work at its best for landscape is going to be around f5.6 or f8. The lower the better, however it will depend on whiat is the smallest object in the foreground you want to render acceptably sharp. At f8, anything from about 3mm and larger should show up fine throughout the image, with a slight slight loss in contrast over f5.6.