body_class

The timeline below displays how wordpress function body_class has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Displays the class names for the body element.
 *
 * @since 2.8.0
 *
 * @param string|string[] $css_class Optional. Space-separated string or array of class names
 *                                   to add to the class list. Default empty.
 */
function body_class($css_class = '')
{
    // Separates class names with a single space, collates class names for body element.
    echo 'class="' . esc_attr(implode(' ', get_body_class($css_class))) . '"';
}

WordPress Version: 5.6

/**
 * Displays the class names for the body element.
 *
 * @since 2.8.0
 *
 * @param string|string[] $class Space-separated string or array of class names to add to the class list.
 */
function body_class($class = '')
{
    // Separates class names with a single space, collates class names for body element.
    echo 'class="' . esc_attr(implode(' ', get_body_class($class))) . '"';
}

WordPress Version: 5.5

/**
 * Displays the class names for the body element.
 *
 * @since 2.8.0
 *
 * @param string|string[] $class Space-separated string or array of class names to add to the class list.
 */
function body_class($class = '')
{
    // Separates class names with a single space, collates class names for body element.
    echo 'class="' . esc_attr(join(' ', get_body_class($class))) . '"';
}

WordPress Version: 5.4

/**
 * Displays the class names for the body element.
 *
 * @since 2.8.0
 *
 * @param string|string[] $class Space-separated string or array of class names to add to the class list.
 */
function body_class($class = '')
{
    // Separates class names with a single space, collates class names for body element.
    echo 'class="' . join(' ', get_body_class($class)) . '"';
}

WordPress Version: 5.1

/**
 * Displays the class names for the body element.
 *
 * @since 2.8.0
 *
 * @param string|string[] $class Space-separated string or array of class names to add to the class list.
 */
function body_class($class = '')
{
    // Separates class names with a single space, collates class names for body element
    echo 'class="' . join(' ', get_body_class($class)) . '"';
}

WordPress Version: 3.7

/**
 * Display the classes for the body element.
 *
 * @since 2.8.0
 *
 * @param string|array $class One or more classes to add to the class list.
 */
function body_class($class = '')
{
    // Separates classes with a single space, collates classes for body element
    echo 'class="' . join(' ', get_body_class($class)) . '"';
}