[wp-trac] [WordPress Trac] #18220: Put Permalink into body tag for CSS selection
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 22 17:51:07 UTC 2011
#18220: Put Permalink into body tag for CSS selection
--------------------------+-----------------------------
Reporter: DennisSmolek | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Template | Version: 3.2.1
Severity: normal | Keywords:
--------------------------+-----------------------------
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)
2. 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.
3. 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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18220>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list