Add a custom class name to Wordpress body tag?

前端 未结 7 1578
忘掉有多难
忘掉有多难 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:55

    Try this..

        add_filter( 'body_class', 'custom_class' );
    function custom_class( $classes ) {
        if ( !is_front_page() ) {
            $classes[] = 'example';
        }
        return $classes;
    }
    
    0 讨论(0)
提交回复
热议问题