Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#18220 closed enhancement (duplicate)

Put Permalink into body tag for CSS selection

Reported by: dennissmolek's profile DennisSmolek Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Template Keywords:
Focuses: Cc:

Description

At my work we code our sites in a sandbox environment before pushing to the live client servers.
As a front end designer/developer I spend a ton of time working on CSS and one of the most annoying things is when working on specific posts/pages.
On our test server a page may be .page-id-458 but live it may be .page-id-3.
This means any page specific code that I want to limit in scope, I have to adjust each time I push live, and then my dev/live CSS is not synced correctly. Worse, when another dev pulls the live content onto the development service they often wipe the original CSS and are confused when the About Us, or Contact Pages stop working.

There are 3 solutions,

  1. I add inline styles to pages/posts that are then stored in the database, or with a big wrapping div.(not the best idea)
  1. I create a page-template for each page I add, so there is a name associated(WP already adds this with page-template-default)But that would mean adding 1 for each, that would be the exact same as page.php but with different template names. Not efficient. Especially with 30+ pages.
  1. Wordpress starts adding ".pretty-permalink" to the body tag like it does the post/page id. It serves the same purpose, but would work better in the real world of test/publish

a body tag for the "About Us" page would get the .about-us(generated with the permalink) class:
<body class="page page-id-458 about-us page-template">

then with css I scope:
.about-us h3 {}
.about-us #foo {}
.about-us .junk {}

I have sites with 30 or so page specific stylings that I have to do this to every week.
There are code options that I could write and add to functions.php like here: http://codex.wordpress.org/Function_Reference/body_class
but why id doesn't do this by default I have no idea. If I have time I'll write it up and add to this ticket.

Change History (1)

#1 @SergeyBiryukov
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.