Using the body_class filter
// Use the filter 'body_class'
add_filter( 'body_class', 'parent_id_body_class' );
function parent_id_body_class( $classes ) {
// add parent id number to the $classes array
$classes[] = wp_get_post_parent_id( $post_ID );
// return the $classes array
return $classes;
}
Anyway, I recommend you to add some text to the id number, in order to make it more comprehensive, as follows:
// Use the filter 'body_class'
add_filter( 'body_class', 'parent_id_body_class' );
function parent_id_body_class( $classes ) {
// add comprehensive text followed by parent id number to the $classes array
$classes[] = 'parent-id-' . wp_get_post_parent_id( $post_ID );
// return the $classes array
return $classes;
}
I hope it helps.