[wp-hackers] Dynamic Style Sheets

Matt speedboxer at gmail.com
Sun Apr 29 07:31:04 GMT 2007

Why can't you do something like this in header.php:

if (is_single()) {
// your checking or whatever here
// something like if (whatever) {
echo '<link rel="stylesheet" href="path/to/single_stylesheet.css" />';

Just put that after the normal code for the normal stylesheet, and it should
overwrite the settings in the original stylesheet with the ones from

On 4/29/07, Guy Leech <guyleech at gmail.com> wrote:
> 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
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

Matt (speedboxer at gmail.com)
http://mattsblog.ca/ | http://livemp.net/

More information about the wp-hackers mailing list