Covalent organic frameworks (COFs) show promising applications in the adsorption of chemical hazards. However, on-demand design for selective recognition remains a great challenge. It is important for food and environmental safety to make COFs into novel multifunctional adsorbents with selective recognition and hierarchical structure through functionalization and structural regulation. Here, calix[4]arene (CX4) and 5,10,15,20-tetrakis(4-aminophenyl)porphyrin (Tph) were used as building blocks for the rapid preparation of novel hierarchical CX4-Tph-COF with double macrocycles synergistic effects for the first time. CX4-Tph-COF exhibited monodisperse and regular spherical structure. The perfect fusion of double macrocycles and porous COFs enabled CX4-Tph-COF to exhibit excellent host–guest recognition, size-sieving and high adsorption capacity. Meanwhile, adsorption experiments and simulation calculations further verified the recognition mechanism. CX4-Tph-COF had successfully achieved efficient adsorption and detection of mycotoxins in cereals, showing ultra-high sensitivity (LODs of 0.18–21.32 ng/kg), satisfactory recovery (81.7–118 %) and good precision (0.9–9.2 %). This provides a new idea for the design of multifunctional COFs with customizable molecular recognition and has potential applications in the targeted analysis of hazards in food safety and environmental monitoring.