Skip to content

Commit

Permalink
Themes: Add wp-singular to the list of body classes when viewing …
Browse files Browse the repository at this point in the history
…a single post object.

The `wp-singular` class includes a `wp` prefix to avoid conflicts with existing classes. This changeset also updates the `Tests_Post_GetBodyClass` PHPUnit test to include the new CSS class.

Props danielpataki, peterwilsoncc, swissspidy, johnbillion, eceleste, poena, audrasjb, raj198, shailu25.
Fixes #35164.




git-svn-id: https://develop.svn.wordpress.org/trunk@59689 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
audrasjb committed Jan 22, 2025
1 parent 4210d50 commit b8dc43d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wp-includes/post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ function get_body_class( $css_class = '' ) {
$post_id = $post->ID;
$post_type = $post->post_type;

$classes[] = 'wp-singular';

if ( is_page_template() ) {
$classes[] = "{$post_type}-template";

Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/post/getBodyClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function test_singular_body_classes() {
$this->assertContains( 'single-post', $class );
$this->assertContains( "postid-{$post_id}", $class );
$this->assertContains( 'single-format-standard', $class );
$this->assertContains( 'wp-singular', $class );
}

public function test_page_template_body_classes_no_template() {
Expand Down

0 comments on commit b8dc43d

Please sign in to comment.