ruttoa of Web-veistamo
5/29/2017 - 8:09 AM

Add extra classes to multisite body

Add extra classes to multisite body

///////////// Add extra classes to multisite body ////////////
    function multisite_body_classes($classes) {
        $id = get_current_blog_id();
        $blog_name = strtolower(str_replace(' ', '-', trim(get_bloginfo('name'))));
        $slug = str_replace('/','',$GLOBALS['path']);
        global $post;
        $post_slug = $post->post_name;
        $classes[] = 'page-'.$post_slug;
        $classes[] = $slug;
        $classes[] = $blog_name;
        $classes[] = 'site-id-'.$id;
        if ($id != 1){
            $classes[] = 'multisite-child';
        }
        return $classes;
    }
    add_filter('body_class', 'multisite_body_classes');