Add a custom class name to Wordpress body tag?

前端 未结 7 1599
忘掉有多难
忘掉有多难 2021-02-07 03:29

I\'d like to place a directive in my theme\'s functions.php file which appends a classname to the wordpress body tag. Is there a built-in API method for this?

For exampl

7条回答
  •  广开言路
    2021-02-07 03:47

    To add more classes to the filter, just add another line that adds another value in to the array:

    add_filter( 'body_class','my_body_classes' ); function my_body_classes( $classes ) {

    $classes[] = 'class-name';
    $classes[] = 'class-name-two';
    
    return $classes;
    

    }

提交回复
热议问题