Ticket #9514 (closed enhancement: fixed)
Add 'page' class to the get_body_class() function
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.8 |
| Component: | Themes | Version: | 2.8 |
| Severity: | normal | Keywords: | has-patch tested |
| Cc: | ryan |
Description
Currently, there is no 'page' class assigned to the $classes array in the get_body_class() function. Consequently, there would be no way for CSS to target "all pages" with a single selector.
This is my first ticket, so I hope I did this the right way.
I've attached a diff file that adds the following code to wp-includes/post-template.php within the is_page() conditional:
if ($pageID != get_option('page_for_posts'))
$classes[] = 'page';
I feel like this is an important addition to the classes that this function generates.
Attachments
Change History
comment:2
in reply to:
↑ 1
nathanrice — 3 years ago
Replying to filosofo:
I think the conditional is unnecessary; is_page() will be false when querying the page_for_posts page.
Good call. I'm attaching a new diff file that just adds the 'page' class without the conditional.
nathanrice — 3 years ago
-
attachment
post-template.diff
added
post-template.php diff file to add page class to get_body_class()
- Status changed from new to closed
- Resolution set to fixed
comment:5
nathanrice — 3 years ago
Thanks Ryan!!!

I think the conditional is unnecessary; is_page() will be false when querying the page_for_posts page.