Add body class for specific page (home)

Hi everyone!
I’m new here and this is the first time I’m using roots.
My question is about the classes of the body. I went into the base.php and I found a function that comes from the extra.php.
I’m a newbie in php, so I don’t understand what’s happen here.
My goal is to add a class if I’m in the homepage, something like
<body class="<?php if(is_home()){echo "blockScroll"} ?>">
but here I’ve no idea how to achieve that!
Any help is appreciated :slight_smile:


sorry for the delay and thanks for the tip. It solved my problem :slight_smile:

I was having trouble with this as the menu I’m using,, recommended adding no-js to the body tag.

I’m not sure if this is proper because I see other places where it is supposed to be a class of the HTML element.
At any rate, added this line to the body_class function:

$classes[] = 'no-js';

But the class wasn’t visible in the browser code.

I could see that it was being added to the $classes array:

    [0] => home
    [1] => page
    [2] => page-id-8
    [3] => page-template-default
    [4] => logged-in
    [5] => admin-bar
    [6] => no-customize-support
    [7] => no-js
class="home page logged-in admin-bar no-customize-support no-js">


<body class="home page logged-in admin-bar js-enabled customize-support">

Tried changing the class name (no-jsxxx) and lo and behold, there it was! This is because modernizr.js removes it and replaces with js if javascript is enabled in the browser.

How can I also use the controller variables?
I want to check for a specific field before applying a body class.