A method of photonic crystal filter using resonant cavities in two dimensional structures suitable for WDM and DWDM communication applications is proposed. For the design of the structure, movement of defects as resonant cavities is utilized. Tuning the desired wavelengths with characteristics according to ITU-T standard is shown. By changing characteristics such as radius of defects, distance of them from each other and location of defects, a compact optical filter proper for optical integrated circuits is proposed. Also, the combined effect of introduction of variable radius of defects and distances of them from each other, resulted interesting characteristics.