body_class

FILTER wp-includes\post-template.php (ligne 560) github
Filters the taxonomies to generate classes for each individual term. Default is all public taxonomies registered to the post type.
traduction française
Filtre les taxonomies pour générer des classes pour chaque terme individuel. Par défaut, toutes les taxonomies publiques enregistrées pour le type de message.

Paramètres

Entrée :
$css_class = ''
Sortie :
@param string[] $taxonomies List of all taxonomy names to generate classes for.
@param int      $post_id    The post ID.
@param string[] $classes    An array of post class names.
@param string[] $css_class  An array of additional class names added to the post.
@param string[] $classes   An array of post class names.
@param string[] $css_class An array of additional class names added to the post.
@param int      $post_id   The post ID.
@param string|string[] $css_class Optional. Space-separated string or array of class names

Utilisation

Ajouter des classes personnalisées au body

Filtre pour ajouter des classes CSS au tag body.

frontend
add_filter('body_class', 'add_custom_body_classes');
function add_custom_body_classes($classes) {
    if (is_singular('post')) $classes[] = 'single-post-view';
    if (is_user_logged_in()) $classes[] = 'user-authenticated';
    return $classes;
}

Actualités

Chargement des actualités...