diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index ed2ce12f0e..8a2989b9ea 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -578,6 +578,9 @@ function get_body_class( $class = '' ) { $classes[] = 'attachment'; if ( is_404() ) $classes[] = 'error404'; + if ( is_singular() ) { + $classes[] = 'singular'; + } if ( is_single() ) { $post_id = $wp_query->get_queried_object_id(); diff --git a/tests/phpunit/tests/post/getBodyClass.php b/tests/phpunit/tests/post/getBodyClass.php index d7b89e8005..3e3b861a64 100644 --- a/tests/phpunit/tests/post/getBodyClass.php +++ b/tests/phpunit/tests/post/getBodyClass.php @@ -78,4 +78,19 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase { $this->assertContains( "term-$term_id3", get_body_class() ); } + /** + * @ticket 35164 + */ + public function test_singular_body_classes() { + $post_id = self::factory()->post->create(); + $this->go_to( get_permalink( $post_id ) ); + + $class = get_body_class(); + $this->assertContains( "single-post", $class ); + $this->assertContains( "postid-{$post_id}", $class ); + $this->assertContains( "single-format-standard", $class ); + $this->assertContains( "singular", $class ); + + } + }