Una whitelist è un ottimo modo per filtrare molte classi indesiderate aggiunte nel tuo tema. Puoi creare una whitelist dei termini da includere in body_class.
Istruzioni: Aggiungi il seguente codice al file functions.php del tuo tema WordPress per impostare la whitelist body_class.
add_filter('body_class', 'wps_body_class', 10, 2);
function wps_body_class($wp_classes, $extra_classes)
{
// List of classes allowed
$whitelist = array('portfolio', 'home', 'error404');
$wp_classes = array_intersect($wp_classes, $whitelist);
return array_merge($wp_classes, (array) $extra_classes);
}
Potrebbe interessarti anche aggiungere body_class personalizzate utilizzando wp_is_mobile.
Commenti Lascia una risposta