We present the design and analysis of a tunable resonant optical filter based on modulation of the near-field coupling between two subwavelength periodic nanostructures embedded in a Fabry-Pérot cavity. Due to the transverse localization of the optical field in the subwavelength gratings, their relative positioning strongly influences the near-field coupling between them and, thus, affects the resonance of the cavity. Rigorous electromagnetic analysis tools are applied to determine the optical characteristics of the filter with respect to the nanostructure lateral alignment, small variations in the shape of the nanostructures, and the physical separation of the nanostructures.