In bright photodissociation regions (PDRs) associated to massive star formation, the presence of dense clumps that are immersed in a less dense interclump medium is often proposed to explain the difficulty of models to account for the observed gas emission in high-excitation lines. We aim at presenting a comprehensive view of the modeling of the CO rotational ladder in PDRs, including the high-J lines that trace warm molecular gas at PDR interfaces. We observed the 12CO and 13CO ladders in two prototypical PDRs, the Orion Bar and NGC 7023 NW using the instruments onboard Herschel. We also considered line emission from key species in the gas cooling of PDRs (C+, O, H2) and other tracers of PDR edges such as OH and CH+. All the intensities are collected from Herschel observations, the literature and the Spitzer archive and are analyzed using the Meudon PDR code. A grid of models was run to explore the parameter space of only two parameters: thermal gas pressure and a global scaling factor that corrects for approximations in the assumed geometry. We conclude that the emission in the high-J CO lines, which were observed up to Jup=23 in the Orion Bar (Jup=19 in NGC7023), can only originate from small structures of typical thickness of a few 1e-3 pc and at high thermal pressures (Pth~1e8 K cm-3). Compiling data from the literature, we found that the gas thermal pressure increases with the intensity of the UV radiation field given by G0, following a trend in line with recent simulations of the photoevaporation of illuminated edges of molecular clouds. This relation can help rationalising the analysis of high-J CO emission in massive star formation and provides an observational constraint for models that study stellar feedback on molecular clouds.