Add body class to custom post type

your code only works if you are using category taxonomy.
enter image description here

if you are using custom taxonomy like brands you must change your code to this:

function add_category_to_single( $classes ) {
    if ( is_singular() ) {
        global $post;

        $taxonomy = 'brands';
        $terms = get_the_terms( $post->ID, $taxonomy );

        if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
            foreach ( $terms as $term ) {
                $classes[] = $term->slug;
            }
        }
    }

    return $classes;
}

add_filter( 'body_class', 'add_category_to_single' );

enter image description here

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)