A good way to remember how the depth of field is affected by aperture. Is that Ansel Adams belonged to the f64 club. Now as a great landscape photographer unless he wanted a aperture that had a large depth of field. So he chose the large number (small hole) that had a large depth of fields for his era.
Here is video on the subject.
Foreground and background can be out of focus in shallow depth of field.
So a F2 is a narrow depth of field.
F22 is a deep depth of field.