This work presents a density functional theory (DFT)-based embedding technique for the calculation of optical gaps in ionic solids. The approach partitions the supercell of the ionic solid and embeds a small molecule-like cluster in a periodic environment using a cluster-in-periodic embedding method. The environment is treated with DFT, and its influence on the cluster is captured by a DFT-based embedding potential. The optical gap is estimated as the lowest singlet excitation energy of the embedded cluster, obtained using a wave function theory method: second-order approximate coupled-cluster singles and doubles (CC2), and a many-body perturbation theory method: GW approximation combined with the Bethe-Salpeter equation (GW/BSE). The calculated excitation energies are benchmarked against the periodic GW/BSE values, equation-of-motion coupled-cluster singles and doubles (EOM-CCSD) results, and experiments. Both CC2-in-DFT and GW/BSE-in-DFT deliver excitation energies that are in good agreement with experimental values for several ionic solids (MgO, CaO, LiF, NaF, KF, and LiCl) while incurring negligible computational costs. Notably, GW/BSE-in-DFT exhibits remarkable accuracy with a mean absolute error (MAE) of just 0.38 eV with respect to experiments, demonstrating the effectiveness of the embedding strategy. In addition, the versatility of the method is highlighted by investigating the optical gap of a 2D MgCl2 system and the excitation energy of an oxygen vacancy in MgO, with results in good agreement with reported values.