A hook that runs only when the theme is previewed May 22, 2022 by Tarik Billa I think you could use the ?preview=true in the url something like : if ($GET['preview']) { // your hook or function }