[wp-hackers] Dynamic Style Sheets

Guy Leech guyleech at gmail.com
Sun Apr 29 07:15:29 GMT 2007

On 4/29/07, Andy Skelton <skeltoac at gmail.com> wrote:
> Having your style.php call is_single() will never work. The request
> for the HTML and the request for the CSS are distinct HTTP requests
> and the server has no way to connect them.

 I see. I guess no use going down that avenue then.

You can add a dynamic stylesheet without hacking core files by using
> the action hook wp_head. You can pass your dynamic stylesheet script
> any kind of information via its URL query string.

I thought of this a while back, and implemented it, but I like pretty
looking code, and lengthy GETs don't do it for me. Though I implemented it
in my 'header.php', rather than as a hook.

But why would you do any of these things? A static stylesheet can
> serve you just as well. Instead of changing the CSS to fit the WP
> context, use the WP context to change the markup so that different ids
> or classes trigger the presentational changes you want.
> You might want to use the Sandbox theme over at http://plaintxt.org/
> and save yourself a lot of time. :-)
> Andy

I'm trying to change the width of my content based on the number of
paragraphs in a post, and this is the only way I can think of doing it. It's
horizontal scrolling, so I have to define a set width, and I don't want to
create unnecessary room by setting 'width: 1000%;' or something.

It boils down to I like messing with things, the harder, the more rewarding.

Thanks for the reply
 - Guy

More information about the wp-hackers mailing list